Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'maven-publish'
}

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -39,7 +39,6 @@ import ru.betterend.world.surface.SurfaceBuilders;
public class BetterEnd implements ModInitializer {
public static final String MOD_ID = "betterend";
public static final Logger LOGGER = Logger.get();
@Override
public void onInitialize() {
EndPortals.loadPortals();
@ -72,15 +71,14 @@ public class BetterEnd implements ModInitializer {
GuideBookItem.register();
}
FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class)
.forEach(BetterEndPlugin::register);
FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class).forEach(BetterEndPlugin::register);
Configs.saveConfigs();
if (hasGuideBook()) {
PlayerAdvancementsEvents.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway");
if (advId.equals(advancement.getId())) {
player.giveItemStack(new ItemStack(GuideBookItem.GUIDE_BOOK));
player.addItem(new ItemStack(GuideBookItem.GUIDE_BOOK));
}
});
}

View file

@ -1,10 +1,10 @@
package ru.betterend.blocks;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.blocks.basis.EndAnvilBlock;
import ru.betterend.item.material.EndToolMaterial;
import ru.betterend.patterns.Patterns;
@ -24,7 +24,7 @@ public class AeterniumAnvil extends EndAnvilBlock {
}
@Override
public IntegerProperty getDESTRUCTION() {
public IntegerProperty getDestructionProperty() {
return DESTRUCTION;
}

View file

@ -5,17 +5,20 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import ru.betterend.blocks.basis.BlockBase;
public class AeterniumBlock extends BlockBase {
public AeterniumBlock() {
super(FabricBlockSettings.of(Material.METAL, MaterialColor.COLOR_GRAY).hardness(65F).resistance(1200F)
.requiresTool().sounds(SoundType.NETHERITE_BLOCK));
super(FabricBlockSettings.of(Material.METAL, MaterialColor.COLOR_GRAY)
.hardness(65F)
.resistance(1200F)
.requiresCorrectToolForDrops()
.sound(SoundType.NETHERITE_BLOCK));
}
@Environment(EnvType.CLIENT)

View file

@ -2,12 +2,12 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
public class AmaranitaCapBlock extends BlockBase {
public AmaranitaCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
}
}

View file

@ -2,15 +2,15 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class AmaranitaHymenophoreBlock extends BlockBase implements IRenderTypeable {
public AmaranitaHymenophoreBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
}
@Override

View file

@ -3,11 +3,11 @@ package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
@ -16,7 +16,7 @@ import ru.betterend.util.MHelper;
public class AncientEmeraldIceBlock extends BlockBase {
public AncientEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).ticksRandomly());
super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).randomTicks());
}
@Override
@ -39,14 +39,14 @@ public class AncientEmeraldIceBlock extends BlockBase {
if (state.is(Blocks.WATER)) {
world.setBlockAndUpdate(pos, EndBlocks.EMERALD_ICE.defaultBlockState());
makeParticles(world, pos, random);
} else if (state.is(EndBlocks.EMERALD_ICE)) {
}
else if (state.is(EndBlocks.EMERALD_ICE)) {
world.setBlockAndUpdate(pos, EndBlocks.DENSE_EMERALD_ICE.defaultBlockState());
makeParticles(world, pos, random);
}
}
private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5,
0.5, 0);
world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
}
}

View file

@ -5,24 +5,26 @@ import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.block.AbstractGlassBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.level.block.SoundType;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndTags;
import ru.betterend.util.MHelper;
public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTypeable, IColorProvider {
@ -31,13 +33,19 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
private static final int MAX_DROP = 4;
public AuroraCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES)
.suffocates((state, world, pos) -> false).hardness(1F).resistance(1F).sounds(SoundType.GLASS)
.luminance(15).nonOpaque());
super(FabricBlockSettings.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES)
.breakByTool(EndTags.HAMMERS)
.hardness(1F)
.resistance(1F)
.luminance(15)
.noOcclusion()
.isSuffocating((state, world, pos) -> false)
.sound(SoundType.GLASS));
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1;
@ -59,7 +67,9 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
@Override
public ItemColor getItemProvider() {
return (stack, tintIndex) -> MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
return (stack, tintIndex) -> {
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
};
}
@Override
@ -93,7 +103,11 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
}
static {
COLORS = new Vec3i[] { new Vec3i(247, 77, 161), new Vec3i(120, 184, 255), new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255) };
COLORS = new Vec3i[] {
new Vec3i(247, 77, 161),
new Vec3i(120, 184, 255),
new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255)
};
}
}

View file

@ -1,36 +1,38 @@
package ru.betterend.blocks;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.util.StringIdentifiable;
import ru.betterend.registry.EndPortals;
public class BlockProperties {
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.of("shape", HydraluxShape.class);
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class);
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
public static final EnumProperty<PentaShape> PENTA_SHAPE = EnumProperty.of("shape", PentaShape.class);
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.create("shape", HydraluxShape.class);
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.class);
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.create("shape", TripleShape.class);
public static final EnumProperty<PentaShape> PENTA_SHAPE = EnumProperty.create("shape", PentaShape.class);
public static final BooleanProperty TRANSITION = BooleanProperty.of("transition");
public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light");
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
public static final BooleanProperty IS_FLOOR = BooleanProperty.of("is_floor");
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
public static final BooleanProperty SMALL = BooleanProperty.of("small");
public static final BooleanProperty TRANSITION = BooleanProperty.create("transition");
public static final BooleanProperty HAS_LIGHT = BooleanProperty.create("has_light");
public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item");
public static final BooleanProperty IS_FLOOR = BooleanProperty.create("is_floor");
public static final BooleanProperty NATURAL = BooleanProperty.create("natural");
public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
public static final BooleanProperty SMALL = BooleanProperty.create("small");
public static final IntegerProperty DESTRUCTION_LONG = IntegerProperty.of("destruction", 0, 8);
public static final IntegerProperty DESTRUCTION = IntegerProperty.of("destruction", 0, 2);
public static final IntegerProperty ROTATION = IntegerProperty.of("rotation", 0, 3);
public static final IntegerProperty FULLNESS = IntegerProperty.of("fullness", 0, 3);
public static final IntegerProperty COLOR = IntegerProperty.of("color", 0, 7);
public static final IntegerProperty PORTAL = IntegerProperty.of("portal", 0, EndPortals.getCount());
public static final IntegerProperty SIZE = IntegerProperty.of("size", 0, 7);
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 3);
public static final IntegerProperty DESTRUCTION_LONG = IntegerProperty.create("destruction", 0, 8);
public static final IntegerProperty DESTRUCTION = IntegerProperty.create("destruction", 0, 2);
public static final IntegerProperty ROTATION = IntegerProperty.create("rotation", 0, 3);
public static final IntegerProperty FULLNESS = IntegerProperty.create("fullness", 0, 3);
public static final IntegerProperty COLOR = IntegerProperty.create("color", 0, 7);
public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public static final IntegerProperty SIZE = IntegerProperty.create("size", 0, 7);
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
public static enum TripleShape implements StringIdentifiable {
TOP("top"), MIDDLE("middle"), BOTTOM("bottom");
public static enum TripleShape implements StringRepresentable {
TOP("top"),
MIDDLE("middle"),
BOTTOM("bottom");
private final String name;
@ -39,7 +41,7 @@ public class BlockProperties {
}
@Override
public String asString() {
public String getSerializedName() {
return name;
}
@ -49,8 +51,12 @@ public class BlockProperties {
}
}
public static enum PedestalState implements StringIdentifiable {
PEDESTAL_TOP("pedestal_top"), COLUMN_TOP("column_top"), BOTTOM("bottom"), PILLAR("pillar"), COLUMN("column"),
public static enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"),
BOTTOM("bottom"),
PILLAR("pillar"),
COLUMN("column"),
DEFAULT("default");
private final String name;
@ -60,7 +66,7 @@ public class BlockProperties {
}
@Override
public String asString() {
public String getSerializedName() {
return this.name;
}
@ -70,10 +76,13 @@ public class BlockProperties {
}
}
public static enum HydraluxShape implements StringIdentifiable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true), FLOWER_BIG_TOP("flower_big_top", true),
FLOWER_SMALL_BOTTOM("flower_small_bottom", true), FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false), ROOTS("roots", false);
public static enum HydraluxShape implements StringRepresentable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true),
FLOWER_BIG_TOP("flower_big_top", true),
FLOWER_SMALL_BOTTOM("flower_small_bottom", true),
FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false),
ROOTS("roots", false);
private final String name;
private final boolean glow;
@ -84,7 +93,7 @@ public class BlockProperties {
}
@Override
public String asString() {
public String getSerializedName() {
return name;
}
@ -98,8 +107,12 @@ public class BlockProperties {
}
}
public static enum PentaShape implements StringIdentifiable {
BOTTOM("bottom"), PRE_BOTTOM("pre_bottom"), MIDDLE("middle"), PRE_TOP("pre_top"), TOP("top");
public static enum PentaShape implements StringRepresentable {
BOTTOM("bottom"),
PRE_BOTTOM("pre_bottom"),
MIDDLE("middle"),
PRE_TOP("pre_top"),
TOP("top");
private final String name;
@ -108,7 +121,7 @@ public class BlockProperties {
}
@Override
public String asString() {
public String getSerializedName() {
return name;
}
@ -118,9 +131,13 @@ public class BlockProperties {
}
}
public static enum LumecornShape implements StringIdentifiable {
LIGHT_TOP("light_top", 15), LIGHT_TOP_MIDDLE("light_top_middle", 15), LIGHT_MIDDLE("light_middle", 15),
LIGHT_BOTTOM("light_bottom", 15), MIDDLE("middle", 0), BOTTOM_BIG("bottom_big", 0),
public static enum LumecornShape implements StringRepresentable {
LIGHT_TOP("light_top", 15),
LIGHT_TOP_MIDDLE("light_top_middle", 15),
LIGHT_MIDDLE("light_middle", 15),
LIGHT_BOTTOM("light_bottom", 15),
MIDDLE("middle", 0),
BOTTOM_BIG("bottom_big", 0),
BOTTOM_SMALL("bottom_small", 0);
private final String name;
@ -132,7 +149,7 @@ public class BlockProperties {
}
@Override
public String asString() {
public String getSerializedName() {
return name;
}

View file

@ -1,10 +1,13 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.SoundType;
public class BlockSounds {
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F, SoundEvents.BLOCK_STONE_BREAK,
SoundEvents.BLOCK_WART_BLOCK_STEP, SoundEvents.BLOCK_STONE_PLACE, SoundEvents.BLOCK_STONE_HIT,
SoundEvents.BLOCK_STONE_FALL);
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F,
SoundEvents.STONE_BREAK,
SoundEvents.WART_BLOCK_STEP,
SoundEvents.STONE_PLACE,
SoundEvents.STONE_HIT,
SoundEvents.STONE_FALL);
}

View file

@ -3,7 +3,7 @@ package ru.betterend.blocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.UpDownPlantBlock;
import ru.betterend.registry.EndBlocks;

View file

@ -2,17 +2,17 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
@ -20,22 +20,21 @@ public class BlueVineLanternBlock extends BlockBase {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public BlueVineLanternBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK)
.luminance(15));
this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.getValue(NATURAL) ? world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE : true;
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE;
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
}
else {
return state;
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.blocks.basis.FurBlock;
@ -22,30 +21,24 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
if (h < height + 1) {
return;
}
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
for (int i = 1; i < height; i++) {
BlocksHelper.setWithoutUpdate(world, pos.up(i),
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, pos.above(i), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithoutUpdate(world, pos.up(height),
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
placeLantern(world, pos.up(height + 1));
BlocksHelper.setWithoutUpdate(world, pos.above(height), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
placeLantern(world, pos.above(height + 1));
}
private void placeLantern(WorldGenLevel world, BlockPos pos) {
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.HORIZONTAL) {
BlockPos p = pos.relative(dir);
if (world.isAir(p)) {
BlocksHelper.setWithoutUpdate(world, p,
EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, dir));
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
if (world.isAir(pos.up())) {
BlocksHelper.setWithoutUpdate(world, pos.up(),
EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, Direction.UP));
if (world.isEmptyBlock(pos.above())) {
BlocksHelper.setWithoutUpdate(world, pos.above(), EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP));
}
}
@ -55,7 +48,7 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -2,24 +2,22 @@ package ru.betterend.blocks;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import com.google.common.collect.Lists;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
public class BoluxMushroomBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 9, 15);
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15);
public BoluxMushroomBlock() {
super(10);
@ -31,22 +29,22 @@ public class BoluxMushroomBlock extends EndPlantBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}

View file

@ -5,21 +5,21 @@ import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
@ -28,8 +28,8 @@ public class BrimstoneBlock extends BlockBase {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public BrimstoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).ticksRandomly());
setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false));
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).randomTicks());
registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
}
@Override
@ -38,14 +38,13 @@ public class BrimstoneBlock extends BlockBase {
}
@Override
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
ItemStack itemStack) {
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
if (world.isClientSide()) {
updateChunks((ClientLevel) world, pos);
}
}
public void onBroken(LevelAccessor world, BlockPos pos, BlockState state) {
public void destroy(LevelAccessor world, BlockPos pos, BlockState state) {
if (world.isClientSide()) {
updateChunks((ClientLevel) world, pos);
}
@ -59,41 +58,45 @@ public class BrimstoneBlock extends BlockBase {
int z2 = (pos.getZ() + 2) >> 4;
for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) {
world.scheduleBlockRenders(x, y, z);
world.setSectionDirtyWithNeighbors(x, y, z);
}
}
}
@Override
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
boolean deactivate = true;
for (Direction dir: BlocksHelper.DIRECTIONS) {
if (world.getFluidState(pos.relative(dir)).getFluid().equals(Fluids.WATER)) {
if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) {
deactivate = false;
break;
}
}
if (state.getValue(ACTIVATED)) {
if (deactivate) {
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, false));
} else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) {
world.setBlockAndUpdate(pos, defaultBlockState().setValue(ACTIVATED, false));
}
else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) {
Direction dir = BlocksHelper.randomDirection(random);
BlockPos side = pos.relative(dir);
BlockState sideState = world.getBlockState(side);
if (sideState.getBlock() instanceof SulphurCrystalBlock) {
if (sideState.get(SulphurCrystalBlock.AGE) < 2 && sideState.get(SulphurCrystalBlock.WATERLOGGED)) {
int age = sideState.get(SulphurCrystalBlock.AGE) + 1;
world.setBlockAndUpdate(side, sideState.with(SulphurCrystalBlock.AGE, age));
if (sideState.getValue(SulphurCrystalBlock.AGE) < 2 && sideState.getValue(SulphurCrystalBlock.WATERLOGGED)) {
int age = sideState.getValue(SulphurCrystalBlock.AGE) + 1;
world.setBlockAndUpdate(side, sideState.setValue(SulphurCrystalBlock.AGE, age));
}
} else if (sideState.getFluidState().getFluid() == Fluids.WATER) {
}
else if (sideState.getFluidState().getType() == Fluids.WATER) {
BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.with(SulphurCrystalBlock.FACING, dir).with(SulphurCrystalBlock.WATERLOGGED, true)
.with(SulphurCrystalBlock.AGE, 0);
.setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.WATERLOGGED, true)
.setValue(SulphurCrystalBlock.AGE, 0);
world.setBlockAndUpdate(side, crystal);
}
}
} else if (!deactivate && !state.getValue(ACTIVATED)) {
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, true));
}
else if (!deactivate && !state.getValue(ACTIVATED)) {
world.setBlockAndUpdate(pos, defaultBlockState().setValue(ACTIVATED, true));
}
}
}

View file

@ -6,30 +6,33 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
public class BubbleCoralBlock extends UnderwaterPlantBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 14, 16);
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16);
public BubbleCoralBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.CORAL).breakByHand(true).noCollision());
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.CORAL_BLOCK)
.noCollission());
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Environment(EnvType.CLIENT)
@ -41,17 +44,17 @@ public class BubbleCoralBlock extends UnderwaterPlantBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -1,15 +1,13 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import com.google.common.collect.Lists;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.VineBlock;
import ru.betterend.registry.EndBlocks;
@ -25,22 +23,23 @@ public class BulbVineBlock extends VineBlock {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB));
} else if (MHelper.RANDOM.nextInt(8) == 0) {
}
else if (MHelper.RANDOM.nextInt(8) == 0) {
return Lists.newArrayList(new ItemStack(EndBlocks.BULB_VINE_SEED));
} else {
}
else {
return Lists.newArrayList();
}
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
boolean canPlace = super.canPlaceAt(state, world, pos);
return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace
: canPlace && world.getBlockState(pos.below()).is(this);
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
boolean canPlace = super.canSurvive(state, world, pos);
return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace : canPlace && world.getBlockState(pos.below()).is(this);
}
}

View file

@ -7,17 +7,17 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndLanternBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -25,21 +25,26 @@ import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTypeable, BlockPatterned {
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(4, 4, 4, 12, 16, 12);
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(4, 0, 4, 12, 12, 12);
private static final VoxelShape SHAPE_CEIL = Block.box(4, 4, 4, 12, 16, 12);
private static final VoxelShape SHAPE_FLOOR = Block.box(4, 0, 4, 12, 12, 12);
public BulbVineLanternBlock() {
this(FabricBlockSettings.of(Material.METAL).sounds(SoundType.LANTERN).hardness(1).resistance(1)
.breakByTool(FabricToolTags.PICKAXES).materialColor(MaterialColor.LIGHT_GRAY).requiresTool()
.luminance(15));
this(FabricBlockSettings.of(Material.METAL)
.hardness(1)
.resistance(1)
.breakByTool(FabricToolTags.PICKAXES)
.materialColor(MaterialColor.COLOR_LIGHT_GRAY)
.luminance(15)
.requiresCorrectToolForDrops()
.sound(SoundType.LANTERN));
}
public BulbVineLanternBlock(FabricBlockSettings settings) {
public BulbVineLanternBlock(Properties settings) {
super(settings);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
}
@ -62,7 +67,8 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
map.put("%metal%", getMetalTexture(blockId));
if (block.contains("item") || block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, map);
} else {
}
else {
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, map);
}
}

View file

@ -13,7 +13,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
return getColor();
};

View file

@ -1,12 +1,11 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.tags.BlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -15,23 +14,20 @@ import ru.betterend.util.BlocksHelper;
public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState up = world.getBlockState(pos.up());
return up.isIn(EndTags.GEN_TERRAIN) || up.isIn(BlockTags.LOGS) || up.isIn(BlockTags.LEAVES);
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState up = world.getBlockState(pos.above());
return up.is(EndTags.GEN_TERRAIN) || up.is(BlockTags.LOGS) || up.is(BlockTags.LEAVES);
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1;
if (h > 2) {
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate(world, pos.down(i),
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, pos.below(i), EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithoutUpdate(world, pos.down(h),
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, pos.below(h), EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
}
}
}

View file

@ -4,18 +4,18 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -27,8 +27,8 @@ public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeabl
private static final VoxelShape SHAPE_BIG;
public CavePumpkinBlock() {
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15));
setDefaultState(getDefaultState().with(SMALL, false));
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).lightLevel((state) -> state.getValue(SMALL) ? 10 : 15));
registerDefaultState(defaultBlockState().setValue(SMALL, false));
}
@Override
@ -42,25 +42,24 @@ public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeabl
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED))
: Collections.singletonList(new ItemStack(this));
return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
}
static {
VoxelShape lantern = Block.createCuboidShape(1, 0, 1, 15, 13, 15);
VoxelShape cap = Block.createCuboidShape(0, 12, 0, 16, 15, 16);
VoxelShape top = Block.createCuboidShape(5, 15, 5, 11, 16, 11);
SHAPE_BIG = VoxelShapes.union(lantern, cap, top);
VoxelShape lantern = Block.box(1, 0, 1, 15, 13, 15);
VoxelShape cap = Block.box(0, 12, 0, 16, 15, 16);
VoxelShape top = Block.box(5, 15, 5, 11, 16, 11);
SHAPE_BIG = Shapes.or(lantern, cap, top);
lantern = Block.createCuboidShape(1, 7, 1, 15, 13, 15);
cap = Block.createCuboidShape(4, 12, 4, 12, 15, 12);
top = Block.createCuboidShape(6, 15, 6, 10, 16, 10);
SHAPE_SMALL = VoxelShapes.union(lantern, cap, top);
lantern = Block.box(1, 7, 1, 15, 13, 15);
cap = Block.box(4, 12, 4, 12, 15, 12);
top = Block.box(6, 15, 6, 10, 16, 10);
SHAPE_SMALL = Shapes.or(lantern, cap, top);
}
}

View file

@ -1,73 +1,69 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.up());
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.above());
return isTerrain(down);
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE);
BlockState down = world.getBlockState(pos.below());
if (down.getMaterial().isReplaceable()
|| (down.is(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) {
if (down.getMaterial().isReplaceable() || (down.is(EndBlocks.CAVE_PUMPKIN) && down.getValue(BlockProperties.SMALL))) {
if (age < 3) {
world.setBlockAndUpdate(pos, state.with(AGE, age + 1));
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
}
if (age == 2) {
world.setBlockAndUpdate(pos.below(),
EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, true));
} else if (age == 3) {
world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(BlockProperties.SMALL, true));
}
else if (age == 3) {
world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState());
}
}
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
}
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
state = super.updateShape(state, facing, neighborState, world, pos, neighborPos);
if (state.is(this) && state.getValue(BlockProperties.AGE) > 1) {
BlockState down = world.getBlockState(pos.below());
if (!down.is(EndBlocks.CAVE_PUMPKIN)) {
state = state.with(BlockProperties.AGE, 1);
state = state.setValue(BlockProperties.AGE, 1);
}
}
return state;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -6,16 +6,16 @@ import java.util.EnumMap;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -26,7 +26,7 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public ChandelierBlock(Block source) {
super(FabricBlockSettings.copyOf(source).noCollision().nonOpaque().requiresTool().luminance(15));
super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops());
}
@Override
@ -35,7 +35,7 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@ -50,11 +50,14 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
} else if (block.contains("ceil")) {
}
else if (block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath());
} else if (block.contains("wall")) {
}
else if (block.contains("wall")) {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath());
} else {
}
else {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath());
}
}
@ -65,11 +68,11 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(5, 0, 5, 11, 13, 11));
BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(5, 3, 5, 11, 16, 11));
BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.0, 0.0, 0.5, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 1.0, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.UP, Block.box(5, 0, 5, 11, 13, 11));
BOUNDING_SHAPES.put(Direction.DOWN, Block.box(5, 3, 5, 11, 16, 11));
BOUNDING_SHAPES.put(Direction.NORTH, Shapes.box(0.0, 0.0, 0.5, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, Shapes.box(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, Shapes.box(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
}
}

View file

@ -1,16 +1,15 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
public class CharniaBlock extends UnderwaterPlantBlock {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return sideCoversSmallSquare(world, pos.below(), Direction.UP)
&& world.getFluidState(pos).getFluid() == Fluids.WATER;
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return canSupportCenter(world, pos.below(), Direction.UP) && world.getFluidState(pos).getType() == Fluids.WATER;
}
}

View file

@ -1,12 +1,12 @@
package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
public class DenseSnowBlock extends BlockBase {
public DenseSnowBlock() {
super(FabricBlockSettings.of(Material.SNOW_BLOCK).strength(0.2F).sounds(SoundType.SNOW));
super(FabricBlockSettings.of(Material.SNOW).strength(0.2F).sound(SoundType.SNOW));
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
@ -19,7 +19,7 @@ public class DragonTreeSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS);
}
}

View file

@ -8,28 +8,28 @@ import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.TransparentBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.world.LightType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HalfTransparentBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EmeraldIceBlock extends TransparentBlock implements IRenderTypeable, BlockPatterned {
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTypeable, BlockPatterned {
public EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE));
}
@ -40,17 +40,16 @@ public class EmeraldIceBlock extends TransparentBlock implements IRenderTypeable
}
@Override
public void afterBreak(Level world, Player player, BlockPos pos, BlockState state,
@Nullable BlockEntity blockEntity, ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
super.playerDestroy(world, player, pos, state, blockEntity, stack);
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) {
if (world.getDimension().isUltrawarm()) {
if (world.dimensionType().ultraWarm()) {
world.removeBlock(pos, false);
return;
}
Material material = world.getBlockState(pos.below()).getMaterial();
if (material.blocksMovement() || material.isLiquid()) {
if (material.blocksMotion() || material.isLiquid()) {
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
}
}
@ -59,18 +58,19 @@ public class EmeraldIceBlock extends TransparentBlock implements IRenderTypeable
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (world.getLightLevel(LightType.BLOCK, pos) > 11 - state.getOpacity(world, pos)) {
if (world.getBrightness(LightLayer.BLOCK, pos) > 11 - state.getLightBlock(world, pos)) {
this.melt(state, world, pos);
}
}
protected void melt(BlockState state, Level world, BlockPos pos) {
if (world.getDimension().isUltrawarm()) {
if (world.dimensionType().ultraWarm()) {
world.removeBlock(pos, false);
} else {
}
else {
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
world.updateNeighbor(pos, Blocks.WATER, pos);
world.neighborChanged(pos, Blocks.WATER, pos);
}
}

View file

@ -10,26 +10,26 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -38,32 +38,33 @@ import ru.betterend.util.MHelper;
public class EndLilyBlock extends UnderwaterPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(2, 0, 2, 14, 6, 14);
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
public EndLilyBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> {
return state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0;
}).noCollision());
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
.noCollission());
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return state.getValue(SHAPE) == TripleShape.TOP ? Blocks.AIR.defaultBlockState()
: Blocks.WATER.defaultBlockState();
} else {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return state.getValue(SHAPE) == TripleShape.TOP ? Blocks.AIR.defaultBlockState() : Blocks.WATER.defaultBlockState();
}
else {
return state;
}
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
Vec3d vec3d = state.getModelOffset(view, pos);
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos);
VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
return shape.offset(vec3d.x, vec3d.y, vec3d.z);
return shape.move(vec3d.x, vec3d.y, vec3d.z);
}
@Override
@ -73,18 +74,19 @@ public class EndLilyBlock extends UnderwaterPlantBlock {
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultBlockState()
: Fluids.WATER.getStill(false);
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource(false);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
if (state.getValue(SHAPE) == TripleShape.TOP) {
return world.getBlockState(pos.below()).getBlock() == this;
} else if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
}
else if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
return isTerrain(world.getBlockState(pos.below()));
} else {
BlockState up = world.getBlockState(pos.up());
}
else {
BlockState up = world.getBlockState(pos.above());
BlockState down = world.getBlockState(pos.below());
return up.getBlock() == this && down.getBlock() == this;
}
@ -93,25 +95,24 @@ public class EndLilyBlock extends UnderwaterPlantBlock {
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.TOP) {
return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)),
new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
}
return Collections.emptyList();
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.END_LILY_SEED);
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -1,10 +1,9 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.material.Fluids;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -14,24 +13,21 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
if (canGrow(world, pos)) {
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.BOTTOM));
BlockPos up = pos.up();
while (world.getFluidState(up).isStill()) {
BlocksHelper.setWithoutUpdate(world, up,
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.MIDDLE));
up = up.up();
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.BOTTOM));
BlockPos up = pos.above();
while (world.getFluidState(up).isSource()) {
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.MIDDLE));
up = up.above();
}
BlocksHelper.setWithoutUpdate(world, up,
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGrow(WorldGenLevel world, BlockPos pos) {
BlockPos up = pos.up();
while (world.getBlockState(up).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
up = up.up();
BlockPos up = pos.above();
while (world.getBlockState(up).getFluidState().getType().equals(Fluids.WATER.getSource())) {
up = up.above();
}
return world.isAir(up);
return world.isEmptyBlock(up);
}
}

View file

@ -7,26 +7,26 @@ import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.MHelper;
public class EndLotusFlowerBlock extends EndPlantBlock {
private static final VoxelShape SHAPE_OUTLINE = Block.createCuboidShape(2, 0, 2, 14, 14, 14);
private static final VoxelShape SHAPE_COLLISION = Block.createCuboidShape(0, 0, 0, 16, 2, 16);
private static final VoxelShape SHAPE_OUTLINE = Block.box(2, 0, 2, 14, 14, 14);
private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16);
public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).nonOpaque().luminance(15));
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
}
@Override
@ -35,17 +35,17 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE;
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_COLLISION;
}
@ -57,7 +57,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.END_LOTUS_SEED);
}
}

View file

@ -3,23 +3,23 @@ package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.fluid.WaterFluid;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.WaterFluid;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
@ -28,18 +28,18 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeable {
public static final EnumProperty<Direction> HORIZONTAL_FACING = Properties.HORIZONTAL_FACING;
public static final EnumProperty<Direction> HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VSHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16);
public EndLotusLeafBlock() {
super(FabricBlockSettings.of(Material.PLANT).nonOpaque().sounds(SoundType.WET_GRASS));
super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below());
return !down.getFluidState().isEmpty() && down.getFluidState().getFluid() instanceof WaterFluid;
return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid;
}
@Override
@ -48,7 +48,7 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return VSHAPE;
}
@ -58,7 +58,7 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
}
@ -69,7 +69,7 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.END_LOTUS_SEED);
}
}

View file

@ -1,13 +1,12 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -17,47 +16,46 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
if (canGrow(world, pos)) {
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().with(EndLotusStemBlock.LEAF, true);
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState()
.with(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).with(EndLotusStemBlock.WATERLOGGED, true);
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.LEAF, true);
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).setValue(EndLotusStemBlock.WATERLOGGED, true);
BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, roots);
MutableBlockPos bpos = new MutableBlockPos().set(pos);
bpos.setY(bpos.getY() + 1);
while (world.getFluidState(bpos).isStill()) {
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.WATERLOGGED, true));
while (world.getFluidState(bpos).isSource()) {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.WATERLOGGED, true));
bpos.setY(bpos.getY() + 1);
}
int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1;
TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE;
Direction dir = BlocksHelper.randomHorizontal(random);
BlockPos leafCenter = bpos.immutable().offset(dir);
BlockPos leafCenter = bpos.immutable().relative(dir);
if (hasLeaf(world, leafCenter)) {
generateLeaf(world, leafCenter);
BlocksHelper.setWithoutUpdate(world, bpos,
startLeaf.with(EndLotusStemBlock.SHAPE, shape).with(EndLotusStemBlock.FACING, dir));
} else {
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, shape));
BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.setValue(EndLotusStemBlock.SHAPE, shape).setValue(EndLotusStemBlock.FACING, dir));
}
else {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape));
}
bpos.setY(bpos.getY() + 1);
for (int i = 1; i <= height; i++) {
if (!world.isAir(bpos)) {
if (!world.isEmptyBlock(bpos)) {
bpos.setY(bpos.getY() - 1);
BlocksHelper.setWithoutUpdate(world, bpos, flower);
bpos.setY(bpos.getY() - 1);
stem = world.getBlockState(bpos);
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, TripleShape.TOP));
return;
}
BlocksHelper.setWithoutUpdate(world, bpos, stem);
bpos.setY(bpos.getY() + 1);
}
if (!world.isAir(bpos) || height < 0) {
if (!world.isEmptyBlock(bpos) || height < 0) {
bpos.setY(bpos.getY() - 1);
}
@ -67,40 +65,38 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
if (!stem.is(EndBlocks.END_LOTUS_STEM)) {
stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
if (!world.getBlockState(bpos.north()).getFluidState().isEmpty()) {
stem = stem.with(EndLotusStemBlock.WATERLOGGED, true);
stem = stem.setValue(EndLotusStemBlock.WATERLOGGED, true);
}
}
if (world.getBlockState(bpos.offset(dir)).is(EndBlocks.END_LOTUS_LEAF)) {
stem = stem.with(EndLotusStemBlock.LEAF, true).with(EndLotusStemBlock.FACING, dir);
if (world.getBlockState(bpos.relative(dir)).is(EndBlocks.END_LOTUS_LEAF)) {
stem = stem.setValue(EndLotusStemBlock.LEAF, true).setValue(EndLotusStemBlock.FACING, dir);
}
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGrow(WorldGenLevel world, BlockPos pos) {
MutableBlockPos bpos = new MutableBlockPos();
bpos.set(pos);
while (world.getBlockState(bpos).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
while (world.getBlockState(bpos).getFluidState().getType().equals(Fluids.WATER.getSource())) {
bpos.setY(bpos.getY() + 1);
}
return world.isAir(bpos) && world.isAir(bpos.up());
return world.isEmptyBlock(bpos) && world.isEmptyBlock(bpos.above());
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf
.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i ++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2),
leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
@ -112,7 +108,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z ++) {
p.setZ(pos.getZ() + z);
if (world.isAir(p) && !world.getFluidState(p.below()).isEmpty())
if (world.isEmptyBlock(p) && !world.getFluidState(p.below()).isEmpty())
count ++;
}
}

View file

@ -5,47 +5,46 @@ import java.util.Map;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRenderTypeable {
public static final EnumProperty<Direction> FACING = Properties.FACING;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final BooleanProperty LEAF = BooleanProperty.of("leaf");
public class EndLotusStemBlock extends BlockBase implements SimpleWaterloggedBlock, IRenderTypeable {
public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty LEAF = BooleanProperty.create("leaf");
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final Map<Axis, VoxelShape> SHAPES = Maps.newEnumMap(Axis.class);
public EndLotusStemBlock() {
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE)
.with(LEAF, false).with(FACING, Direction.UP));
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(SHAPE, TripleShape.MIDDLE).setValue(LEAF, false).setValue(FACING, Direction.UP));
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis());
}
@ -56,16 +55,14 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
return this.defaultBlockState()
.with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER)
.with(FACING, ctx.getSide());
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
}
@Override
@ -74,15 +71,14 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
if ((Boolean) state.getValue(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return state;
}
@ -93,8 +89,8 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend
}
static {
SHAPES.put(Axis.X, Block.createCuboidShape(0, 6, 6, 16, 10, 10));
SHAPES.put(Axis.Y, Block.createCuboidShape(6, 0, 6, 10, 16, 10));
SHAPES.put(Axis.Z, Block.createCuboidShape(6, 6, 0, 10, 10, 16));
SHAPES.put(Axis.X, Block.box(0, 6, 6, 16, 10, 10));
SHAPES.put(Axis.Y, Block.box(6, 0, 6, 10, 16, 10));
SHAPES.put(Axis.Z, Block.box(6, 6, 0, 10, 10, 16));
}
}

View file

@ -7,30 +7,28 @@ import java.util.Map;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.patterns.Patterns;
public class EndPathBlock extends BlockBaseNotFull {
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 15, 16);
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
public EndPathBlock(Block source) {
super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> {
return false;
}));
super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; }));
if (source instanceof EndTerrainBlock) {
EndTerrainBlock terrain = (EndTerrainBlock) source;
terrain.setPathBlock(this);
@ -47,12 +45,12 @@ public class EndPathBlock extends BlockBaseNotFull {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}

View file

@ -2,10 +2,9 @@ package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.world.level.block.Block;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.patterns.Patterns;

View file

@ -6,29 +6,29 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.NetherPortalBlock;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.world.level.dimension.DimensionType;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IColorProvider;
@ -42,8 +42,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
public static final IntegerProperty PORTAL = BlockProperties.PORTAL;
public EndPortalBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getExplosionResistance())
.luminance(15));
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getExplosionResistance()).luminance(15));
}
@Override
@ -56,8 +55,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (random.nextInt(100) == 0) {
world.playLocalSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.PORTAL_AMBIENT,
SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
world.playLocalSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.PORTAL_AMBIENT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
}
double x = pos.getX() + random.nextDouble();
@ -74,24 +72,24 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
return state;
}
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (world.isClientSide() || !validate(entity))
return;
if (world.isClientSide || !validate(entity)) return;
entity.setPortalCooldown();
ServerLevel currentWorld = (ServerLevel) world;
MinecraftServer server = currentWorld.getServer();
ServerLevel targetWorld = EndPortals.getLevel(server, state.getValue(PORTAL));
ServerLevel targetWorld = EndPortals.getWorld(server, state.getValue(PORTAL));
boolean isInEnd = currentWorld.dimension().equals(Level.END);
ServerLevel destination = isInEnd ? targetWorld : server.getLevel(Level.END);
BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity);
if (exitPos == null)
return;
if (exitPos == null) return;
if (entity instanceof ServerPlayer) {
ServerPlayer player = (ServerPlayer) entity;
teleportPlayer(player, destination, exitPos);
@ -106,14 +104,13 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
}
private boolean validate(Entity entity) {
return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()
&& !entity.isOnPortalCooldown();
return !entity.isPassenger() && !entity.isVehicle() &&
entity.canChangeDimensions() && !entity.isOnPortalCooldown();
}
private void teleportPlayer(ServerPlayer player, ServerLevel destination, BlockPos exitPos) {
if (player.isCreative()) {
player.teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yRot,
player.xRot);
player.teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yRot, player.xRot);
} else {
TeleportingEntity teleEntity = (TeleportingEntity) player;
teleEntity.beSetExitPos(exitPos);
@ -126,23 +123,20 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
return ERenderLayer.TRANSLUCENT;
}
private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos,
Entity entity) {
if (targetWorld == null)
return null;
private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos, Entity entity) {
if (targetWorld == null) return null;
Registry<DimensionType> registry = targetWorld.registryAccess().dimensionTypes();
ResourceLocation targetWorldId = targetWorld.dimension().location();
ResourceLocation currentWorldId = currentWorld.dimension().location();
double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).coordinateScale();
double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).coordinateScale();
double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier;
BlockPos.MutableBlockPos basePos = currentPos.mutable().set(currentPos.getX() * multiplier, currentPos.getY(),
currentPos.getZ() * multiplier);
BlockPos.MutableBlockPos basePos = currentPos.mutable().set(currentPos.getX() * multiplier, currentPos.getY(), currentPos.getZ() * multiplier);
BlockPos.MutableBlockPos checkPos = basePos.mutable();
BlockState currentState = currentWorld.getBlockState(currentPos);
int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1;
checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this,
state -> state.is(this) && state.getValue(PORTAL).equals(currentState.getValue(PORTAL)));
checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this, state -> state.is(this) &&
state.getValue(PORTAL).equals(currentState.getValue(PORTAL)));
if (checkPos != null) {
BlockState checkState = targetWorld.getBlockState(checkPos);
Axis axis = checkState.getValue(AXIS);
@ -156,7 +150,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
entity.rotate(Rotation.CLOCKWISE_90);
entityDir = entityDir.getClockWise();
}
return checkPos.move(entityDir);
return checkPos.relative(entityDir);
}
return null;
}
@ -165,10 +159,8 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
return findCenter(world, pos, axis, 1);
}
private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis,
int step) {
if (step > 8)
return pos;
private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis, int step) {
if (step > 8) return pos;
BlockState right, left;
Direction rightDir, leftDir;
rightDir = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
@ -189,7 +181,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> EndPortals.getColor(state.getValue(PORTAL));
}

View file

@ -2,12 +2,12 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.BlockBase;
public class EndStoneBlock extends BlockBase {
public EndStoneBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(SoundType.STONE));
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sound(SoundType.STONE));
}
}

View file

@ -8,85 +8,89 @@ import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockRenderType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.HorizontalFacingBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import ru.betterend.blocks.basis.BaseBlockWithEntity;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
public class EndStoneSmelter extends BaseBlockWithEntity {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final BooleanProperty LIT = Properties.LIT;
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final BooleanProperty LIT = BlockStateProperties.LIT;
public static final String ID = "end_stone_smelter";
public EndStoneSmelter() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY).hardness(4F).resistance(100F)
.requiresTool().sounds(SoundType.STONE));
this.setDefaultState(this.stateManager.defaultBlockState().with(FACING, Direction.NORTH).with(LIT, false));
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY)
.hardness(4F)
.resistance(100F)
.requiresCorrectToolForDrops()
.sound(SoundType.STONE));
this.registerDefaultState(this.stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(LIT, false));
}
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide) {
return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
} else {
this.openScreen(world, pos, player);
return ActionResult.CONSUME;
return InteractionResult.CONSUME;
}
}
private void openScreen(Level world, BlockPos pos, Player player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
player.openHandledScreen((EndStoneSmelterBlockEntity) blockEntity);
player.openMenu((EndStoneSmelterBlockEntity) blockEntity);
}
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.defaultBlockState().with(FACING, ctx.getPlayerFacing().getOpposite());
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
public BlockEntity newBlockEntity(BlockGetter world) {
return new EndStoneSmelterBlockEntity();
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
EndStoneSmelterBlockEntity smelterBlockEntity = (EndStoneSmelterBlockEntity) blockEntity;
for (int i = 0; i < smelterBlockEntity.size(); i++) {
ItemStack item = smelterBlockEntity.getStack(i);
for (int i = 0; i < smelterBlockEntity.getContainerSize(); i++) {
ItemStack item = smelterBlockEntity.getItem(i);
if (!item.isEmpty()) {
drop.add(item);
}
@ -96,28 +100,28 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
}
@Override
public boolean hasComparatorOutput(BlockState state) {
public boolean hasAnalogOutputSignal(BlockState state) {
return true;
}
@Override
public int getComparatorOutput(BlockState state, Level world, BlockPos pos) {
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
//TODO
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos));
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return (BlockState) state.with(FACING, rotation.rotate((Direction) state.getValue(FACING)));
return (BlockState)state.setValue(FACING, rotation.rotate((Direction)state.getValue(FACING)));
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return state.rotate(mirror.getRotation((Direction)state.getValue(FACING)));
}
@ -133,16 +137,15 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
double y = pos.getY();
double z = pos.getZ() + 0.5D;
if (random.nextDouble() < 0.1D) {
world.playLocalSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F,
1.0F, false);
world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
}
Direction direction = (Direction)state.getValue(FACING);
Direction.Axis axis = direction.getAxis();
double defOffset = random.nextDouble() * 0.6D - 0.3D;
double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset;
double offX = axis == Direction.Axis.X ? direction.getStepX() * 0.52D : defOffset;
double offY = random.nextDouble() * 9.0D / 16.0D;
double offZ = axis == Direction.Axis.Z ? direction.getOffsetZ() * 0.52D : defOffset;
double offZ = axis == Direction.Axis.Z ? direction.getStepZ() * 0.52D : defOffset;
world.addParticle(ParticleTypes.SMOKE, x + offX, y + offY, z + offZ, 0.0D, 0.0D, 0.0D);
}
}

View file

@ -9,31 +9,31 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SnowBlock;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import net.minecraft.world.chunk.light.ChunkLightProvider;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SnowLayerBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.lighting.LayerLightEngine;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.patterns.Patterns;
@ -41,8 +41,7 @@ public class EndTerrainBlock extends BlockBase {
private Block pathBlock;
public EndTerrainBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND)
.ticksRandomly());
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sound(BlockSounds.TERRAIN_SOUND).randomTicks());
}
public void setPathBlock(Block roadBlock) {
@ -50,19 +49,18 @@ public class EndTerrainBlock extends BlockBase {
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
if (pathBlock != null && player.getMainHandStack().getItem().isIn(FabricToolTags.SHOVELS)) {
world.playLocalSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
if (player != null && !player.isCreative()) {
player.getMainHandStack().damage(1, world.random, (ServerPlayer) player);
if (!player.isCreative()) {
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
}
}
return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
}
return ActionResult.FAIL;
return InteractionResult.FAIL;
}
@Override
@ -81,16 +79,18 @@ public class EndTerrainBlock extends BlockBase {
}
}
protected boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
BlockPos blockPos = pos.up();
@Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getLevel() == 8) {
}
else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
blockState.getOpacity(worldView, blockPos));
}
else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}

View file

@ -3,23 +3,26 @@ package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import ru.betterend.blocks.basis.BlockBase;
public class EnderBlock extends BlockBase {
public EnderBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708).hardness(5F).resistance(6F)
.requiresTool().sounds(SoundType.STONE));
super(FabricBlockSettings.of(Material.STONE, MaterialColor.WARPED_WART_BLOCK)
.hardness(5F)
.resistance(6F)
.requiresCorrectToolForDrops()
.sound(SoundType.STONE));
}
@Environment(EnvType.CLIENT)
public int getColor(BlockState state, BlockView world, BlockPos pos) {
public int getColor(BlockState state, BlockGetter world, BlockPos pos) {
return 0xFF005548;
}
}

View file

@ -7,13 +7,13 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import ru.betterend.util.MHelper;
public class EndstoneDustBlock extends FallingBlock {
@ -21,7 +21,8 @@ public class EndstoneDustBlock extends FallingBlock {
private static final int COLOR = MHelper.color(226, 239, 168);
public EndstoneDustBlock() {
super(FabricBlockSettings.copyOf(Blocks.SAND).breakByTool(FabricToolTags.SHOVELS)
super(FabricBlockSettings.copyOf(Blocks.SAND)
.breakByTool(FabricToolTags.SHOVELS)
.materialColor(Blocks.END_STONE.defaultMaterialColor()));
}
@ -31,7 +32,7 @@ public class EndstoneDustBlock extends FallingBlock {
}
@Environment(EnvType.CLIENT)
public int getColor(BlockState state, BlockView world, BlockPos pos) {
public int getDustColor(BlockState state, BlockGetter world, BlockPos pos) {
return COLOR;
}
}

View file

@ -1,27 +1,25 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import com.google.common.collect.Lists;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.EternalPedestalEntity;
import ru.betterend.registry.EndBlocks;
@ -33,7 +31,7 @@ public class EternalPedestal extends PedestalBlock {
public EternalPedestal() {
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
this.setDefaultState(getDefaultState().with(ACTIVATED, false));
this.registerDefaultState(defaultBlockState().setValue(ACTIVATED, false));
}
@Override
@ -56,12 +54,12 @@ public class EternalPedestal extends PedestalBlock {
ritual.disablePortal(portalId);
}
}
world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, false).with(HAS_LIGHT, false));
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, false).setValue(HAS_LIGHT, false));
} else {
ItemStack itemStack = pedestal.getStack(0);
ResourceLocation id = Registry.ITEM.getId(itemStack.getItem());
ItemStack itemStack = pedestal.getItem(0);
ResourceLocation id = Registry.ITEM.getKey(itemStack.getItem());
if (EndPortals.isAvailableItem(id)) {
world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, true).with(HAS_LIGHT, true));
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, true).setValue(HAS_LIGHT, true));
if (pedestal.hasRitual()) {
pedestal.getRitual().checkStructure();
} else {
@ -74,29 +72,27 @@ public class EternalPedestal extends PedestalBlock {
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
BlockState updated = super.updateShape(state, direction, newState, world, pos, posFrom);
if (!updated.is(this))
return updated;
if (!updated.is(this)) return updated;
if (!this.isPlaceable(updated)) {
return updated.with(ACTIVATED, false);
return updated.setValue(ACTIVATED, false);
}
return updated;
}
@Override
public float calcBlockBreakingDelta(BlockState state, Player player, BlockView world, BlockPos pos) {
public float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
return 0.0F;
}
@Override
public float getBlastResistance() {
public float getExplosionResistance() {
return Blocks.BEDROCK.getExplosionResistance();
}
@Override
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
public boolean dropFromExplosion(Explosion explosion) {
return false;
}
@ -104,17 +100,16 @@ public class EternalPedestal extends PedestalBlock {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.is(this)) {
BlockProperties.PedestalState currentState = state.getValue(BlockProperties.PEDESTAL_STATE);
if (currentState.equals(BlockProperties.PedestalState.BOTTOM)
|| currentState.equals(BlockProperties.PedestalState.PILLAR)) {
if (currentState.equals(BlockProperties.PedestalState.BOTTOM) || currentState.equals(BlockProperties.PedestalState.PILLAR)) {
return Lists.newArrayList();
}
}
List<ItemStack> drop = Lists.newArrayList();
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (blockEntity instanceof EternalPedestalEntity) {
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
if (!pedestal.isEmpty()) {
drop.add(pedestal.getStack(0));
drop.add(pedestal.getItem(0));
}
}
return drop;
@ -127,7 +122,7 @@ public class EternalPedestal extends PedestalBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
public BlockEntity newBlockEntity(BlockGetter world) {
return new EternalPedestalEntity();
}
}

View file

@ -1,32 +1,30 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import com.google.common.collect.Lists;
public class EternalRunedFlavolite extends RunedFlavolite {
@Override
public float calcBlockBreakingDelta(BlockState state, Player player, BlockView world, BlockPos pos) {
public float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
return 0.0F;
}
@Override
public float getBlastResistance() {
public float getExplosionResistance() {
return Blocks.BEDROCK.getExplosionResistance();
}
@Override
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
public boolean dropFromExplosion(Explosion explosion) {
return false;
}

View file

@ -2,13 +2,12 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
public class FilaluxLanternBlock extends BlockBase {
public FilaluxLanternBlock() {
super(FabricBlockSettings.of(Material.WOOD).luminance(15).sounds(SoundType.WOOD)
.breakByTool(FabricToolTags.AXES));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WOOD));
}
}

View file

@ -6,27 +6,29 @@ import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.interfaces.ISpetialItem;
public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS)
.breakByHand(true));
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS));
}
@Override
@ -35,13 +37,13 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override

View file

@ -2,13 +2,12 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
public class GlowingHymenophoreBlock extends BlockBase {
public GlowingHymenophoreBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK)
.luminance(15));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
}
}

View file

@ -2,9 +2,9 @@ package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -19,12 +19,12 @@ public class GlowingMossBlock extends EndPlantBlock {
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockView world, BlockPos pos) {
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) {
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
}

View file

@ -2,18 +2,18 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
@ -21,22 +21,26 @@ public class GlowingPillarLuminophorBlock extends BlockBase {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public GlowingPillarLuminophorBlock() {
super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE)
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).strength(0.2F).luminance(15));
this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false));
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE)
.breakByTool(FabricToolTags.SHEARS)
.strength(0.2F)
.luminance(15)
.sound(SoundType.GRASS));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.getValue(NATURAL) ? world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS) : true;
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
}
else {
return state;
}
}

View file

@ -2,13 +2,13 @@ package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.UpDownPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -28,7 +28,7 @@ public class GlowingPillarRootsBlock extends UpDownPlantBlock {
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.GLOWING_PILLAR_SEED);
}
}

View file

@ -4,15 +4,15 @@ import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -21,9 +21,13 @@ import ru.betterend.util.MHelper;
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
public GlowingPillarSeedBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance((state) -> {
return state.getValue(AGE) * 3 + 3;
}).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true).ticksRandomly().noCollision());
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.lightLevel(state -> state.getValue(AGE) * 3 + 3)
.randomTicks()
.noCollission());
}
@Override
@ -37,27 +41,25 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
MutableBlockPos mut = new MutableBlockPos().set(pos);
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState();
if (height < 2) {
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
mut.move(Direction.UP);
} else {
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
mut.move(Direction.UP);
}
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true));
else {
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
mut.move(Direction.UP);
}
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.DIRECTIONS) {
pos = mut.offset(dir);
if (world.isAir(pos)) {
BlocksHelper.setWithUpdate(world, pos,
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, dir));
pos = mut.relative(dir);
if (world.isEmptyBlock(pos)) {
BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
}
}
mut.move(Direction.UP);
if (world.isAir(mut)) {
BlocksHelper.setWithUpdate(world, mut,
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, Direction.UP));
if (world.isEmptyBlock(mut)) {
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP));
}
}
@ -67,7 +69,7 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -7,22 +7,22 @@ import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.util.Mth;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.noise.OpenSimplexNoise;
@ -34,8 +34,11 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public HelixTreeLeavesBlock() {
super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE)
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WART_BLOCK).sounds(SoundType.GRASS)
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE)
.breakByTool(FabricToolTags.SHEARS)
.sound(SoundType.WART_BLOCK)
.sound(SoundType.GRASS)
.strength(0.2F));
}
@ -45,7 +48,7 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
return MHelper.color(237, getGreen(state.getValue(COLOR)), 20);
};
@ -59,11 +62,11 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
double px = ctx.getBlockPos().getX() * 0.1;
double py = ctx.getBlockPos().getY() * 0.1;
double pz = ctx.getBlockPos().getZ() * 0.1;
return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
double py = ctx.getClickedPos().getY() * 0.1;
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
private int getGreen(int color) {
@ -75,8 +78,7 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null) {
if (tool.getItem().isIn(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool.getItem().is(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Collections.singletonList(new ItemStack(this));
}
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
@ -85,7 +87,6 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
}
return Lists.newArrayList();
}
return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING))
: Lists.newArrayList();
return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) : Lists.newArrayList();
}
}

View file

@ -10,18 +10,18 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.blocks.BlockProperties.HydraluxShape;
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -32,10 +32,12 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
public static final EnumProperty<HydraluxShape> SHAPE = BlockProperties.HYDRALUX_SHAPE;
public HydraluxBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> {
return state.getValue(SHAPE).hasGlow() ? 15 : 0;
}).noCollision());
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
.noCollission());
}
@Override
@ -44,31 +46,33 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below());
HydraluxShape shape = state.getValue(SHAPE);
if (shape == HydraluxShape.FLOWER_BIG_TOP || shape == HydraluxShape.FLOWER_SMALL_TOP) {
return down.is(this);
} else if (shape == HydraluxShape.ROOTS) {
return down.is(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.up()).is(this);
} else {
return down.is(this) && world.getBlockState(pos.up()).is(this);
}
else if (shape == HydraluxShape.ROOTS) {
return down.is(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.above()).is(this);
}
else {
return down.is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.HYDRALUX_SAPLING);
}
@ -77,9 +81,9 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
HydraluxShape shape = state.getValue(SHAPE);
if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) {
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
} else if (shape == HydraluxShape.ROOTS) {
return Lists
.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
}
else if (shape == HydraluxShape.ROOTS) {
return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
}
return Collections.emptyList();
}

View file

@ -2,25 +2,29 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import ru.betterend.blocks.basis.BlockBase;
public class HydraluxPetalBlock extends BlockBase {
public HydraluxPetalBlock() {
this(FabricBlockSettings.of(Material.PLANT).materialColor(MaterialColor.SPRUCE).sounds(SoundType.WART_BLOCK)
.breakByTool(FabricToolTags.AXES).hardness(1).resistance(1).breakByHand(true));
this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.AXES)
.breakByHand(true)
.hardness(1)
.resistance(1)
.materialColor(MaterialColor.PODZOL)
.sound(SoundType.WART_BLOCK));
}
public HydraluxPetalBlock(FabricBlockSettings settings) {
public HydraluxPetalBlock(Properties settings) {
super(settings);
}
@Override
public void onLandedUpon(Level world, BlockPos pos, Entity entity, float distance) {
}
public void fallOn(Level world, BlockPos pos, Entity entity, float distance) {}
}

View file

@ -16,7 +16,7 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
return BlocksHelper.getBlockColor(this);
};

View file

@ -1,12 +1,11 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.HydraluxShape;
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -28,20 +27,18 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
mut.setY(pos.getY());
BlockState state = EndBlocks.HYDRALUX.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
BlocksHelper.setWithoutUpdate(world, pos, state.setValue(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
for (int i = 1; i < h - 2; i++) {
mut.setY(pos.getY() + i);
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE));
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE));
}
mut.setY(mut.getY() + 1);
boolean big = random.nextBoolean();
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE,
big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
mut.setY(mut.getY() + 1);
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE,
big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
}
@Override

View file

@ -8,50 +8,52 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockEntityProvider;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FluidFillable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
import ru.betterend.util.BlocksHelper;
public class HydrothermalVentBlock extends BlockBaseNotFull
implements BlockEntityProvider, FluidFillable, Waterloggable {
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public class HydrothermalVentBlock extends BlockBaseNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15);
public HydrothermalVentBlock() {
super(FabricBlockSettings.of(Material.STONE).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.STONE)
.noCollision().requiresTool());
this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false));
super(FabricBlockSettings.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES)
.sound(SoundType.STONE)
.noCollission()
.requiresCorrectToolForDrops());
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false));
}
@Override
@ -60,70 +62,67 @@ public class HydrothermalVentBlock extends BlockBaseNotFull
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
state = world.getBlockState(pos.below());
return state.is(EndBlocks.SULPHURIC_ROCK.stone);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.WATER.defaultBlockState();
} else if (state.getValue(WATERLOGGED) && facing == Direction.UP && neighborState.is(Blocks.WATER)) {
world.getBlockTickScheduler().schedule(pos, this, 20);
}
else if (state.getValue(WATERLOGGED) && facing == Direction.UP && neighborState.is(Blocks.WATER)) {
world.getBlockTicks().scheduleTick(pos, this, 20);
}
return state;
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
return this.defaultBlockState().with(WATERLOGGED,
worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER);
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
}
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
public BlockEntity newBlockEntity(BlockGetter world) {
return new BlockEntityHydrothermalVent();
}
@Override
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
BlockPos up = pos.up();
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
BlockPos up = pos.above();
if (world.getBlockState(up).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.VENT_BUBBLE_COLUMN);
world.getBlockTickScheduler().schedule(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
}
}
@Override
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
ItemStack itemStack) {
if (world instanceof ServerLevel && state.getValue(WATERLOGGED)
&& world.getBlockState(pos.up()).is(Blocks.WATER)) {
scheduledTick(state, (ServerLevel) world, pos, world.random);
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
if (world instanceof ServerLevel && state.getValue(WATERLOGGED) && world.getBlockState(pos.above()).is(Blocks.WATER)) {
tick(state,(ServerLevel) world, pos, world.random);
}
}
@ -136,7 +135,8 @@ public class HydrothermalVentBlock extends BlockBaseNotFull
double z = pos.getZ() + random.nextDouble();
if (state.getValue(WATERLOGGED)) {
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
} else {
}
else {
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
}
}

View file

@ -1,15 +1,15 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.InfusionPedestalEntity;
import ru.betterend.rituals.InfusionRitual;
@ -39,12 +39,12 @@ public class InfusionPedestal extends PedestalBlock {
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
public BlockEntity newBlockEntity(BlockGetter world) {
return new InfusionPedestalEntity();
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) {
switch(state.getValue(STATE)) {
case PEDESTAL_TOP: {
@ -54,24 +54,24 @@ public class InfusionPedestal extends PedestalBlock {
return SHAPE_DEFAULT;
}
default: {
return super.getOutlineShape(state, world, pos, context);
return super.getShape(state, world, pos, context);
}
}
}
return super.getOutlineShape(state, world, pos, context);
return super.getShape(state, world, pos, context);
}
static {
VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16);
VoxelShape pedestalTop = Block.createCuboidShape(1, 9, 1, 15, 11, 15);
VoxelShape pedestalDefault = Block.createCuboidShape(1, 13, 1, 15, 15, 15);
VoxelShape pillar = Block.createCuboidShape(3, 0, 3, 13, 9, 13);
VoxelShape pillarDefault = Block.createCuboidShape(3, 4, 3, 13, 13, 13);
VoxelShape eyeDefault = Block.createCuboidShape(4, 15, 4, 12, 16, 12);
VoxelShape eyeTop = Block.createCuboidShape(4, 11, 4, 12, 12, 12);
VoxelShape basin = VoxelShapes.union(basinDown, basinUp);
SHAPE_DEFAULT = VoxelShapes.union(basin, pillarDefault, pedestalDefault, eyeDefault);
SHAPE_PEDESTAL_TOP = VoxelShapes.union(pillar, pedestalTop, eyeTop);
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
VoxelShape pedestalTop = Block.box(1, 9, 1, 15, 11, 15);
VoxelShape pedestalDefault = Block.box(1, 13, 1, 15, 15, 15);
VoxelShape pillar = Block.box(3, 0, 3, 13, 9, 13);
VoxelShape pillarDefault = Block.box(3, 4, 3, 13, 13, 13);
VoxelShape eyeDefault = Block.box(4, 15, 4, 12, 16, 12);
VoxelShape eyeTop = Block.box(4, 11, 4, 12, 12, 12);
VoxelShape basin = Shapes.or(basinDown, basinUp);
SHAPE_DEFAULT = Shapes.or(basin, pillarDefault, pedestalDefault, eyeDefault);
SHAPE_PEDESTAL_TOP = Shapes.or(pillar, pedestalTop, eyeTop);
}
}

View file

@ -6,21 +6,21 @@ import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SlimeBlock;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.core.Vec3i;
import net.minecraft.core.Registry;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SlimeBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.interfaces.IRenderTypeable;
@ -44,11 +44,11 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
double px = ctx.getBlockPos().getX() * 0.1;
double py = ctx.getBlockPos().getY() * 0.1;
double pz = ctx.getBlockPos().getZ() * 0.1;
return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
double py = ctx.getClickedPos().getY() * 0.1;
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
@Override
@ -83,7 +83,7 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
float delta = (float) state.getValue(COLOR) / 7F;
int r = Mth.floor(Mth.lerp(delta, colorStart.getX() / 255F, colorEnd.getX() / 255F) * 255F);

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
@ -19,8 +19,7 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS)
|| world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);
}
}

View file

@ -2,19 +2,18 @@ package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.blocks.BlockProperties.PentaShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -34,23 +33,25 @@ public class LanceleafBlock extends EndPlantBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
PentaShape shape = state.getValue(SHAPE);
if (shape == PentaShape.TOP) {
return world.getBlockState(pos.below()).is(this);
} else if (shape == PentaShape.BOTTOM) {
return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).is(this);
} else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
}
else if (shape == PentaShape.BOTTOM) {
return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.above()).is(this);
}
else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
}
else {
return state;
}
}
@ -60,7 +61,6 @@ public class LanceleafBlock extends EndPlantBlock {
if (state.getValue(SHAPE) == PentaShape.BOTTOM) {
return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
}
return MHelper.RANDOM.nextBoolean() ? Collections.emptyList()
: Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() : Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
}
}

View file

@ -1,13 +1,12 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.BlockProperties.PentaShape;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
@ -24,18 +23,14 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
}
int rotation = random.nextInt(4);
MutableBlockPos mut = new MutableBlockPos().set(pos);
BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().with(BlockProperties.ROTATION, rotation);
BlocksHelper.setWithoutUpdate(world, mut, plant.with(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().setValue(BlockProperties.ROTATION, rotation);
BlocksHelper.setWithoutUpdate(world, mut, plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
for (int i = 2; i < height - 2; i++) {
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
}
@Override
@ -44,7 +39,7 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -4,44 +4,44 @@ import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
public class LargeAmaranitaBlock extends EndPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
private static final VoxelShape SHAPE_TOP = VoxelShapes.union(Block.createCuboidShape(1, 3, 1, 15, 16, 15),
SHAPE_BOTTOM);
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 14, 12);
private static final VoxelShape SHAPE_TOP = Shapes.or(Block.box(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM);
public LargeAmaranitaBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.luminance((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0)
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true));
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0));
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN)
|| state.is(EndBlocks.MOSSY_DRAGON_BONE);
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
}
@Override
@ -50,14 +50,16 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) {
return isTerrain(world.getBlockState(pos.below())) && world.getBlockState(pos.up()).is(this);
} else if (shape == TripleShape.TOP) {
return isTerrain(world.getBlockState(pos.below())) && world.getBlockState(pos.above()).is(this);
}
else if (shape == TripleShape.TOP) {
return world.getBlockState(pos.below()).is(this);
} else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
}
else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@ -67,12 +69,12 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -7,21 +7,21 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.LumecornShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
@ -32,13 +32,15 @@ import ru.betterend.registry.EndTags;
import ru.betterend.util.MHelper;
public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable {
public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.of("shape", LumecornShape.class);
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(6, 0, 6, 10, 16, 10);
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(6, 0, 6, 10, 8, 10);
public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.create("shape", LumecornShape.class);
private static final VoxelShape SHAPE_BOTTOM = Block.box(6, 0, 6, 10, 16, 10);
private static final VoxelShape SHAPE_TOP = Block.box(6, 0, 6, 10, 8, 10);
public LumecornBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).hardness(0.5F)
.luminance((state) -> {
super(FabricBlockSettings.of(Material.WOOD)
.breakByTool(FabricToolTags.AXES)
.hardness(0.5F)
.lightLevel((state) -> {
return state.getValue(SHAPE).getLight();
}));
}
@ -54,28 +56,30 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
LumecornShape shape = state.getValue(SHAPE);
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) {
return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
} else if (shape == LumecornShape.LIGHT_TOP) {
return world.getBlockState(pos.below()).is(EndTags.END_GROUND);
}
else if (shape == LumecornShape.LIGHT_TOP) {
return world.getBlockState(pos.below()).is(this);
} else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
}
else {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
}
else {
return state;
}
}
@ -84,16 +88,14 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
LumecornShape shape = state.getValue(SHAPE);
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
return Collections
.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
return Collections.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
}
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD))
: Collections.emptyList();
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList();
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
LumecornShape shape = state.getValue(SHAPE);
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
return new ItemStack(EndBlocks.LUMECORN_SEED);

View file

@ -1,11 +1,10 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.AbstractBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
@ -22,7 +21,7 @@ public class LumecornSeedBlock extends EndPlantWithAgeBlock {
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -5,20 +5,20 @@ import java.util.Queue;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FluidBlock;
import net.minecraft.world.level.block.FluidDrainable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Tuple;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -26,19 +26,18 @@ import ru.betterend.registry.EndBlocks;
public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeable {
public MengerSpongeBlock() {
super(FabricBlockSettings.copyOf(Blocks.SPONGE).nonOpaque());
super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion());
}
@Override
public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (absorbWater(world, pos)) {
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState());
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (absorbWater(world, pos)) {
return EndBlocks.MENGER_SPONGE_WET.defaultBlockState();
}
@ -46,46 +45,44 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab
}
private boolean absorbWater(LevelAccessor world, BlockPos pos) {
Queue<Pair<BlockPos, Integer>> queue = Lists.newLinkedList();
queue.add(new Pair<BlockPos, Integer>(pos, 0));
Queue<Tuple<BlockPos, Integer>> queue = Lists.newLinkedList();
queue.add(new Tuple<BlockPos, Integer>(pos, 0));
int i = 0;
while (!queue.isEmpty()) {
Pair<BlockPos, Integer> pair = queue.poll();
BlockPos blockPos = (BlockPos) pair.getLeft();
int j = (Integer) pair.getRight();
Tuple<BlockPos, Integer> pair = queue.poll();
BlockPos blockPos = (BlockPos) pair.getA();
int j = (Integer) pair.getB();
Direction[] var8 = Direction.values();
int var9 = var8.length;
for (int var10 = 0; var10 < var9; ++var10) {
Direction direction = var8[var10];
BlockPos blockPos2 = blockPos.offset(direction);
BlockPos blockPos2 = blockPos.relative(direction);
BlockState blockState = world.getBlockState(blockPos2);
FluidState fluidState = world.getFluidState(blockPos2);
Material material = blockState.getMaterial();
if (fluidState.isIn(FluidTags.WATER)) {
if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock())
.tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) {
if (fluidState.is(FluidTags.WATER)) {
if (blockState.getBlock() instanceof BucketPickup && ((BucketPickup) blockState.getBlock()).takeLiquid(world, blockPos2, blockState) != Fluids.EMPTY) {
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
queue.add(new Tuple<BlockPos, Integer>(blockPos2, j + 1));
}
} else if (blockState.getBlock() instanceof FluidBlock) {
world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
}
} else if (material == Material.UNDERWATER_PLANT
|| material == Material.REPLACEABLE_UNDERWATER_PLANT) {
BlockEntity blockEntity = blockState.getBlock().hasBlockEntity()
? world.getBlockEntity(blockPos2)
: null;
dropStacks(blockState, world, blockPos2, blockEntity);
world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3);
else if (blockState.getBlock() instanceof LiquidBlock) {
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
queue.add(new Tuple<BlockPos, Integer>(blockPos2, j + 1));
}
}
else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity blockEntity = blockState.getBlock().isEntityBlock() ? world.getBlockEntity(blockPos2) : null;
dropResources(blockState, world, blockPos2, blockEntity);
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i;
if (j < 6) {
queue.add(new Tuple<BlockPos, Integer>(blockPos2, j + 1));
}
}
}

View file

@ -5,20 +5,20 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.GameRules;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -27,27 +27,26 @@ import ru.betterend.util.BlocksHelper;
public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTypeable {
public MengerSpongeWetBlock() {
super(FabricBlockSettings.copyOf(Blocks.WET_SPONGE).nonOpaque());
super(FabricBlockSettings.copyOf(Blocks.WET_SPONGE).noOcclusion());
}
@Override
public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (world.getDimension().isUltrawarm()) {
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3);
world.syncWorldEvent(2009, pos, 0);
world.playLocalSound((Player) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0F,
(1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (world.dimensionType().ultraWarm()) {
world.setBlock(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3);
world.levelEvent(2009, pos, 0);
world.playSound((Player) null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0F, (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
}
}
@Override
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
Direction direction = Direction.random(random);
Direction direction = Direction.getRandom(random);
if (direction != Direction.UP) {
BlockPos blockPos = pos.relative(direction);
BlockState blockState = world.getBlockState(blockPos);
if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) {
if (!state.canOcclude() || !blockState.isFaceSturdy(world, blockPos, direction.getOpposite())) {
double x = (double) pos.getX();
double y = (double) pos.getY();
double z = (double) pos.getZ();
@ -55,20 +54,24 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
y -= 0.05;
x += random.nextDouble();
z += random.nextDouble();
} else {
}
else {
y += random.nextDouble() * 0.8;
if (direction.getAxis() == Direction.Axis.X) {
z += random.nextDouble();
if (direction == Direction.EAST) {
++x;
} else {
}
else {
x += 0.05;
}
} else {
}
else {
x += random.nextDouble();
if (direction == Direction.SOUTH) {
++z;
} else {
}
else {
z += 0.05;
}
}
@ -80,15 +83,14 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
}
@Override
public void onBreak(Level world, BlockPos pos, BlockState state, Player player) {
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
if (!world.isClientSide()) {
world.syncWorldEvent(2001, pos, getRawIdFromState(state));
world.levelEvent(2001, pos, getId(state));
}
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && (player == null || !player.isCreative())) {
ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
new ItemStack(this));
world.spawnEntity(drop);
if (world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && (player == null || !player.isCreative())) {
ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this));
world.addFreshEntity(drop);
}
}
@ -99,6 +101,6 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getStill(false);
return Fluids.WATER.getSource(false);
}
}

View file

@ -5,25 +5,25 @@ import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SnowBlock;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.WorldView;
import net.minecraft.world.chunk.light.ChunkLightProvider;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SnowLayerBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.lighting.LayerLightEngine;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.betterend.blocks.basis.EndPillarBlock;
import ru.betterend.registry.EndBlocks;
public class MossyDragonBoneBlock extends EndPillarBlock {
public MossyDragonBoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).ticksRandomly());
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks());
}
@Override
@ -38,20 +38,20 @@ public class MossyDragonBoneBlock extends EndPillarBlock {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.BONE_BLOCK.defaultBlockState().with(AXIS, state.getValue(AXIS)));
world.setBlockAndUpdate(pos, Blocks.BONE_BLOCK.defaultBlockState().setValue(AXIS, state.getValue(AXIS)));
}
}
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
BlockPos blockPos = pos.up();
@Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getLevel() == 8) {
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
blockState.getOpacity(worldView, blockPos));
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}

View file

@ -2,13 +2,13 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
@ -16,13 +16,12 @@ public class MossyGlowshroomCapBlock extends BlockBase {
public static final BooleanProperty TRANSITION = BlockProperties.TRANSITION;
public MossyGlowshroomCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
this.setDefaultState(this.stateManager.defaultBlockState().with(TRANSITION, false));
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false));
}
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.defaultBlockState().with(TRANSITION,
EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getBlockPos().below())));
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below())));
}
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
@ -19,8 +19,7 @@ public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS)
|| world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);
}
}

View file

@ -5,24 +5,24 @@ import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SnowBlock;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.WorldView;
import net.minecraft.world.chunk.light.ChunkLightProvider;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SnowLayerBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.lighting.LayerLightEngine;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.betterend.blocks.basis.BlockBase;
public class MossyObsidian extends BlockBase {
public MossyObsidian() {
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).ticksRandomly());
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks());
}
@Override
@ -41,16 +41,15 @@ public class MossyObsidian extends BlockBase {
}
}
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
BlockPos blockPos = pos.up();
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
if (blockState.is(Blocks.SNOW) && (Integer)blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getLevel() == 8) {
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
blockState.getOpacity(worldView, blockPos));
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}

View file

@ -4,16 +4,16 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.pathing.NavigationType;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.PathComputationType;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -30,8 +30,8 @@ public class MurkweedBlock extends EndPlantBlock {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasMobEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addMobEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
}
}
@ -41,7 +41,7 @@ public class MurkweedBlock extends EndPlantBlock {
}
@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false;
}
}

View file

@ -5,20 +5,20 @@ import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.pathing.NavigationType;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.MHelper;
@ -27,17 +27,17 @@ public class NeedlegrassBlock extends EndPlantBlock {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity) {
entity.damage(DamageSource.CACTUS, 0.1F);
entity.hurt(DamageSource.CACTUS, 0.1F);
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
} else {
}
else {
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
}
}
@ -48,7 +48,7 @@ public class NeedlegrassBlock extends EndPlantBlock {
}
@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false;
}
}

View file

@ -5,38 +5,38 @@ import java.util.EnumMap;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable, IRenderTypeable {
public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, IRenderTypeable {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final DirectionProperty FACING = Properties.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = BlockStateProperties.FACING;
private static final EnumMap<Direction, VoxelShape> MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
private static final EnumMap<Direction, VoxelShape> SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
@ -44,15 +44,14 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
private static final EnumMap<Axis, VoxelShape> SMALL_SHAPES = Maps.newEnumMap(Axis.class);
public NeonCactusBlock() {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(state -> {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).lightLevel(state -> {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.TOP) {
return 15;
}
return shape == TripleShape.MIDDLE ? 13 : 10;
}));
setDefaultState(
getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP));
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP));
}
@Override
@ -61,12 +60,10 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
return this.defaultBlockState()
.with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER)
.with(FACING, ctx.getSide());
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
}
@Override
@ -75,20 +72,19 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
if ((Boolean) state.getValue(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return state;
}
@ -99,43 +95,44 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) {
return VoxelShapes.fullCube();
return Shapes.block();
}
Direction dir = state.getValue(FACING);
BlockState next = view.getBlockState(pos.relative(dir));
if (next.is(this)) {
Axis axis = dir.getAxis();
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES.get(axis) : SMALL_SHAPES.get(axis);
} else {
}
else {
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
}
}
static {
MEDIUM_SHAPES.put(Axis.X, Block.createCuboidShape(0, 2, 2, 16, 14, 14));
MEDIUM_SHAPES.put(Axis.Y, Block.createCuboidShape(2, 0, 2, 14, 16, 14));
MEDIUM_SHAPES.put(Axis.Z, Block.createCuboidShape(2, 2, 0, 14, 14, 16));
MEDIUM_SHAPES.put(Axis.X, Block.box(0, 2, 2, 16, 14, 14));
MEDIUM_SHAPES.put(Axis.Y, Block.box(2, 0, 2, 14, 16, 14));
MEDIUM_SHAPES.put(Axis.Z, Block.box(2, 2, 0, 14, 14, 16));
SMALL_SHAPES.put(Axis.X, Block.createCuboidShape(0, 4, 4, 16, 12, 12));
SMALL_SHAPES.put(Axis.Y, Block.createCuboidShape(4, 0, 4, 12, 16, 12));
SMALL_SHAPES.put(Axis.Z, Block.createCuboidShape(4, 4, 0, 12, 12, 16));
SMALL_SHAPES.put(Axis.X, Block.box(0, 4, 4, 16, 12, 12));
SMALL_SHAPES.put(Axis.Y, Block.box(4, 0, 4, 12, 16, 12));
SMALL_SHAPES.put(Axis.Z, Block.box(4, 4, 0, 12, 12, 16));
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(2, 0, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(2, 2, 2, 14, 16, 14));
MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(2, 2, 2, 14, 14, 16));
MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(2, 2, 0, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(2, 2, 2, 16, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 2, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.box(2, 0, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.box(2, 2, 2, 14, 16, 14));
MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.box(2, 2, 2, 14, 14, 16));
MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.box(2, 2, 0, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.box(2, 2, 2, 16, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 2, 2, 14, 14, 14));
SMALL_SHAPES_OPEN.put(Direction.UP, Block.createCuboidShape(4, 0, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.createCuboidShape(4, 4, 4, 12, 16, 12));
SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.createCuboidShape(4, 4, 4, 12, 12, 16));
SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.createCuboidShape(4, 4, 0, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.createCuboidShape(4, 4, 4, 16, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.createCuboidShape(0, 4, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.UP, Block.box(4, 0, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.box(4, 4, 4, 12, 16, 12));
SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.box(4, 4, 4, 12, 12, 16));
SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.box(4, 4, 0, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.box(4, 4, 4, 16, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 4, 4, 12, 12, 12));
}
}

View file

@ -2,10 +2,9 @@ package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.world.level.block.Block;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.patterns.Patterns;

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
@ -19,7 +19,7 @@ public class PythadendronSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM);
}
}

View file

@ -7,34 +7,34 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.client.render.ERenderLayer;
@ -47,19 +47,19 @@ import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IRenderTypeable {
private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.createCuboidShape(1, 0, 1, 15, 16, 15);
private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.createCuboidShape(2, 0, 2, 14, 16, 14);
private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.box(1, 0, 1, 15, 16, 15);
private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.box(2, 0, 2, 14, 16, 14);
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public RespawnObeliskBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).lightLevel((state) -> {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15;
}));
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP;
}
@ -69,9 +69,9 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
for (int i = 0; i < 3; i++) {
if (!world.getBlockState(pos.up(i)).getMaterial().isReplaceable()) {
if (!world.getBlockState(pos.above(i)).getMaterial().isReplaceable()) {
return false;
}
}
@ -79,57 +79,62 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
}
@Override
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
ItemStack itemStack) {
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
state = this.defaultBlockState();
BlocksHelper.setWithUpdate(world, pos, state.with(SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithUpdate(world, pos.up(), state.with(SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithUpdate(world, pos.up(2), state.with(SHAPE, TripleShape.TOP));
BlocksHelper.setWithUpdate(world, pos, state.setValue(SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithUpdate(world, pos.above(), state.setValue(SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithUpdate(world, pos.above(2), state.setValue(SHAPE, TripleShape.TOP));
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) {
if (world.getBlockState(pos.up()).is(this)) {
if (world.getBlockState(pos.above()).is(this)) {
return state;
} else {
}
else {
return Blocks.AIR.defaultBlockState();
}
} else if (shape == TripleShape.MIDDLE) {
if (world.getBlockState(pos.up()).is(this) && world.getBlockState(pos.below()).is(this)) {
}
else if (shape == TripleShape.MIDDLE) {
if (world.getBlockState(pos.above()).is(this) && world.getBlockState(pos.below()).is(this)) {
return state;
} else {
}
else {
return Blocks.AIR.defaultBlockState();
}
} else {
}
else {
if (world.getBlockState(pos.below()).is(this)) {
return state;
} else {
}
else {
return Blocks.AIR.defaultBlockState();
}
}
}
@Override
public void onBreak(Level world, BlockPos pos, BlockState state, Player player) {
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (player.isCreative()) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.MIDDLE) {
BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR);
} else if (shape == TripleShape.TOP) {
BlocksHelper.setWithUpdate(world, pos.down(2), Blocks.AIR);
}
else if (shape == TripleShape.TOP) {
BlocksHelper.setWithUpdate(world, pos.below(2), Blocks.AIR);
}
}
super.onBreak(world, pos, state, player);
super.playerWillDestroy(world, pos, state, player);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
return Lists.newArrayList(new ItemStack(this));
} else {
}
else {
return Lists.newArrayList();
}
}
@ -140,8 +145,8 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
}
@Override
public BlockColor getBlockProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getBlockProvider();
public BlockColor getProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
}
@Override
@ -152,20 +157,20 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
ItemStack itemStack = player.getStackInHand(hand);
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
boolean canActivate = itemStack.getItem() == EndItems.AMBER_GEM && itemStack.getCount() > 5;
if (hand != Hand.MAIN_HAND || !canActivate) {
if (hand != InteractionHand.MAIN_HAND || !canActivate) {
if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) {
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.fail_spawn"), true);
serverPlayerEntity.displayClientMessage(new TranslatableComponent("message.betterend.fail_spawn"), true);
}
return ActionResult.FAIL;
} else if (!world.isClientSide) {
return InteractionResult.FAIL;
}
else if (!world.isClientSide) {
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
serverPlayerEntity.setSpawnPoint(world.dimension(), pos, 0.0F, false, false);
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.set_spawn"), true);
serverPlayerEntity.setRespawnPosition(world.dimension(), pos, 0.0F, false, false);
serverPlayerEntity.displayClientMessage(new TranslatableComponent("message.betterend.set_spawn"), true);
double px = pos.getX() + 0.5;
double py = pos.getY() + 0.5;
double pz = pos.getZ() + 0.5;
@ -176,21 +181,22 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
py1 += 1;
py2 += 2;
} else if (state.getValue(SHAPE) == TripleShape.MIDDLE) {
}
else if (state.getValue(SHAPE) == TripleShape.MIDDLE) {
py1 += 0;
py2 += 1;
} else {
}
else {
py1 -= 2;
}
((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1);
((ServerLevel) world).sendParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1);
}
world.playLocalSound(null, px, py, py, SoundEvents.BLOCK_RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F,
1F);
world.playSound(null, px, py, py, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, 1F);
if (!player.isCreative()) {
itemStack.decrement(6);
itemStack.shrink(6);
}
}
return player.isCreative() ? ActionResult.PASS : ActionResult.success(world.isClientSide);
return player.isCreative() ? InteractionResult.PASS : InteractionResult.sidedSuccess(world.isClientSide);
}
}

View file

@ -2,10 +2,10 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
@ -13,11 +13,10 @@ public class RunedFlavolite extends BlockBase {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public RunedFlavolite() {
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished)
.resistance(Blocks.OBSIDIAN.getExplosionResistance()).luminance(state -> {
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getExplosionResistance()).lightLevel(state -> {
return state.getValue(ACTIVATED) ? 8 : 0;
}));
this.setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false));
this.registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
}
@Override

View file

@ -1,24 +1,24 @@
package ru.betterend.blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.core.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndCropBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public class ShadowBerryBlock extends EndCropBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 8, 15);
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 8, 15);
public ShadowBerryBlock() {
super(EndItems.SHADOW_BERRY_RAW, EndBlocks.SHADOW_GRASS);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
}

View file

@ -4,10 +4,10 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.registry.EndParticles;
public class ShadowGrassBlock extends EndTerrainBlock {
@ -19,8 +19,7 @@ public class ShadowGrassBlock extends EndTerrainBlock {
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random);
if (random.nextInt(32) == 0) {
world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(),
(double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
}
}
}

View file

@ -4,31 +4,31 @@ import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.core.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities;
@ -37,13 +37,12 @@ import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class SilkMothHiveBlock extends BlockBase {
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS;
public SilkMothHiveBlock() {
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque()
.ticksRandomly().breakByHand(true));
this.setDefaultState(getDefaultState().with(FULLNESS, 0));
super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(FULLNESS, 0));
}
@Override
@ -52,9 +51,9 @@ public class SilkMothHiveBlock extends BlockBase {
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction dir = ctx.getPlayerFacing().getOpposite();
return this.defaultBlockState().with(FACING, dir);
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir);
}
@Override
@ -63,7 +62,7 @@ public class SilkMothHiveBlock extends BlockBase {
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@ -74,45 +73,42 @@ public class SilkMothHiveBlock extends BlockBase {
if (!world.getBlockState(spawn).isAir()) {
return;
}
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> {
return true;
}).size();
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
if (count > 6) {
return;
}
SilkMothEntity moth = new SilkMothEntity(EndEntities.SILK_MOTH, world);
moth.refreshPositionAndAngles(spawn.getX() + 0.5, spawn.getY() + 0.5, spawn.getZ() + 0.5, dir.asRotation(), 0);
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
moth.moveTo(spawn.getX() + 0.5, spawn.getY() + 0.5, spawn.getZ() + 0.5, dir.toYRot(), 0);
moth.setDeltaMovement(new Vec3(dir.getStepX() * 0.4, 0, dir.getStepZ() * 0.4));
moth.setHive(world, pos);
world.spawnEntity(moth);
world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
if (hand == Hand.MAIN_HAND) {
ItemStack stack = player.getMainHandStack();
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) {
ItemStack stack = player.getMainHandItem();
if (stack.getItem().is(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.setValue(FULLNESS, 0));
Direction dir = state.getValue(FACING);
double px = pos.getX() + dir.getOffsetX() + 0.5;
double py = pos.getY() + dir.getOffsetY() + 0.5;
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
double px = pos.getX() + dir.getStepX() + 0.5;
double py = pos.getY() + dir.getStepY() + 0.5;
double pz = pos.getZ() + dir.getStepZ() + 0.5;
ItemStack drop = new ItemStack(EndItems.SILK_FIBER, MHelper.randRange(8, 16, world.getRandom()));
ItemEntity entity = new ItemEntity(world, px, py, pz, drop);
world.spawnEntity(entity);
world.addFreshEntity(entity);
if (world.getRandom().nextInt(4) == 0) {
drop = new ItemStack(EndItems.SILK_MOTH_MATRIX);
entity = new ItemEntity(world, px, py, pz, drop);
world.spawnEntity(entity);
world.addFreshEntity(entity);
}
if (!player.isCreative()) {
stack.setDamage(stack.getDamage() + 1);
stack.setDamageValue(stack.getDamageValue() + 1);
}
return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
}
}
return ActionResult.FAIL;
return InteractionResult.FAIL;
}
}

View file

@ -6,39 +6,39 @@ import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.core.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.entity.SilkMothEntity;
@ -50,15 +50,14 @@ import ru.betterend.util.MHelper;
public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE;
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS;
private static final VoxelShape TOP = createCuboidShape(6, 0, 6, 10, 16, 10);
private static final VoxelShape BOTTOM = createCuboidShape(0, 0, 0, 16, 16, 16);
private static final VoxelShape TOP = box(6, 0, 6, 10, 16, 10);
private static final VoxelShape BOTTOM = box(0, 0, 0, 16, 16, 16);
public SilkMothNestBlock() {
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque()
.ticksRandomly());
this.setDefaultState(getDefaultState().with(ACTIVE, true).with(FULLNESS, 0));
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(ACTIVE, true).setValue(FULLNESS, 0));
}
@Override
@ -67,7 +66,7 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(ACTIVE) ? BOTTOM : TOP;
}
@ -77,19 +76,18 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction dir = ctx.getPlayerFacing().getOpposite();
return this.defaultBlockState().with(FACING, dir);
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!state.getValue(ACTIVE)) {
if (sideCoversSmallSquare(world, pos.up(), Direction.DOWN)
|| world.getBlockState(pos.up()).isIn(BlockTags.LEAVES)) {
if (canSupportCenter(world, pos.above(), Direction.DOWN) || world.getBlockState(pos.above()).is(BlockTags.LEAVES)) {
return state;
} else {
}
else {
return Blocks.AIR.defaultBlockState();
}
}
@ -102,7 +100,7 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@ -112,15 +110,15 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
}
@Override
public void onBreak(Level world, BlockPos pos, BlockState state, Player player) {
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (!state.getValue(ACTIVE) && player.isCreative()) {
BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR);
}
BlockState up = world.getBlockState(pos.up());
if (up.is(this) && !up.get(ACTIVE)) {
BlocksHelper.setWithUpdate(world, pos.up(), Blocks.AIR);
BlockState up = world.getBlockState(pos.above());
if (up.is(this) && !up.getValue(ACTIVE)) {
BlocksHelper.setWithUpdate(world, pos.above(), Blocks.AIR);
}
super.onBreak(world, pos, state, player);
super.playerWillDestroy(world, pos, state, player);
}
@Override
@ -136,44 +134,40 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
if (!world.getBlockState(spawn).isAir()) {
return;
}
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> {
return true;
}).size();
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
if (count > 6) {
return;
}
SilkMothEntity moth = new SilkMothEntity(EndEntities.SILK_MOTH, world);
moth.refreshPositionAndAngles(spawn.getX() + 0.5, spawn.getY() + 0.5, spawn.getZ() + 0.5, dir.asRotation(), 0);
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
moth.moveTo(spawn.getX() + 0.5, spawn.getY() + 0.5, spawn.getZ() + 0.5, dir.toYRot(), 0);
moth.setDeltaMovement(new Vec3(dir.getStepX() * 0.4, 0, dir.getStepZ() * 0.4));
moth.setHive(world, pos);
world.spawnEntity(moth);
world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
if (hand == Hand.MAIN_HAND) {
ItemStack stack = player.getMainHandStack();
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(ACTIVE)
&& state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) {
ItemStack stack = player.getMainHandItem();
if (stack.getItem().is(FabricToolTags.SHEARS) && state.getValue(ACTIVE) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.setValue(FULLNESS, 0));
Direction dir = state.getValue(FACING);
double px = pos.getX() + dir.getOffsetX() + 0.5;
double py = pos.getY() + dir.getOffsetY() + 0.5;
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
double px = pos.getX() + dir.getStepX() + 0.5;
double py = pos.getY() + dir.getStepY() + 0.5;
double pz = pos.getZ() + dir.getStepZ() + 0.5;
ItemStack drop = new ItemStack(EndItems.SILK_FIBER, MHelper.randRange(1, 4, world.getRandom()));
ItemEntity entity = new ItemEntity(world, px, py, pz, drop);
world.spawnEntity(entity);
world.addFreshEntity(entity);
drop = new ItemStack(EndItems.SILK_MOTH_MATRIX, MHelper.randRange(1, 3, world.getRandom()));
entity = new ItemEntity(world, px, py, pz, drop);
world.spawnEntity(entity);
world.addFreshEntity(entity);
if (!player.isCreative()) {
stack.setDamage(stack.getDamage() + 1);
stack.setDamageValue(stack.getDamageValue() + 1);
}
return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
}
}
return ActionResult.FAIL;
return InteractionResult.FAIL;
}
}

View file

@ -1,33 +1,31 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.util.BlocksHelper;
public class SmallAmaranitaBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12);
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 10, 12);
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN)
|| state.is(EndBlocks.MOSSY_DRAGON_BONE);
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlockPos bigPos = growBig(world, pos);
if (bigPos != null) {
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().place(world, null, random, bigPos, null)) {
@ -42,9 +40,9 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
Vec3d vec3d = state.getModelOffset(view, pos);
return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z);
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
}
private BlockPos growBig(ServerLevel world, BlockPos pos) {
@ -60,8 +58,10 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
private boolean checkFrame(ServerLevel world, BlockPos pos) {
return world.getBlockState(pos).is(this) && world.getBlockState(pos.south()).is(this)
&& world.getBlockState(pos.east()).is(this) && world.getBlockState(pos.south().east()).is(this);
return world.getBlockState(pos).is(this) &&
world.getBlockState(pos.south()).is(this) &&
world.getBlockState(pos.east()).is(this) &&
world.getBlockState(pos.south().east()).is(this);
}
private void replaceMushroom(ServerLevel world, BlockPos pos) {
@ -71,7 +71,7 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0;
}
}

View file

@ -9,26 +9,26 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Fertilizable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -36,36 +36,39 @@ import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypeable, Fertilizable {
public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypeable, BonemealableBlock {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.NETHER_WART)
.breakByHand(true).noCollision());
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.NETHER_WART)
.noCollission());
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
} else {
}
else {
return Lists.newArrayList();
}
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
BlockState support = world.getBlockState(blockPos);
return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0;
return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0;
}
@Override
@ -74,26 +77,26 @@ public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypea
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.0, 0.0, 0.5, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 1.0, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.UP, Block.box(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, Block.box(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.NORTH, Shapes.box(0.0, 0.0, 0.5, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, Shapes.box(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, Shapes.box(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).is(EndTags.END_GROUND);
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0;
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
EndFeatures.JELLYSHROOM.getFeature().place(world, null, random, pos, null);
}

View file

@ -2,13 +2,18 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.EndPillarBlock;
public class SmaragdantCrystalBlock extends EndPillarBlock {
public SmaragdantCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS)
.luminance(15).hardness(1F).resistance(1F).nonOpaque());
super(FabricBlockSettings.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES)
.luminance(15)
.hardness(1F)
.resistance(1F)
.noOcclusion()
.sound(SoundType.GLASS));
}
}

View file

@ -6,41 +6,44 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.FluidFillable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class SmaragdantCrystalShardBlock extends AttachedBlock
implements IRenderTypeable, Waterloggable, FluidFillable {
public class SmaragdantCrystalShardBlock extends AttachedBlock implements IRenderTypeable, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SmaragdantCrystalShardBlock() {
super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_GREEN)
.breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).luminance(15).requiresTool()
.noCollision());
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_GREEN)
.breakByTool(FabricToolTags.PICKAXES)
.luminance(15)
.sound(SoundType.GLASS)
.requiresCorrectToolForDrops()
.noCollission());
}
@Override
@ -55,50 +58,50 @@ public class SmaragdantCrystalShardBlock extends AttachedBlock
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED);
}
@Override
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState state = super.getPlacementState(ctx);
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx);
if (state != null) {
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return state.with(WATERLOGGED, water);
LevelReader worldView = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
boolean water = worldView.getFluidState(blockPos).getType() == Fluids.WATER;
return state.setValue(WATERLOGGED, water);
}
return null;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).isSideSolidFullSquare(world, blockPos, direction);
return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction);
}
static {
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F));
BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.125, 0.125, 0.125, 0.875F, 0.875F, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.125, 0.125, 0.0, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.125, 0.125, 0.125, 1.0, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.125, 0.125, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F));
BOUNDING_SHAPES.put(Direction.NORTH, Shapes.box(0.125, 0.125, 0.125, 0.875F, 0.875F, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, Shapes.box(0.125, 0.125, 0.0, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.WEST, Shapes.box(0.125, 0.125, 0.125, 1.0, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.EAST, Shapes.box(0.0, 0.125, 0.125, 0.875F, 0.875F, 0.875F));
}
}

View file

@ -9,31 +9,31 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.FluidFillable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -41,14 +41,18 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.util.MHelper;
public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable {
public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 2);
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_YELLOW)
.breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).requiresTool().noCollision());
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_YELLOW)
.breakByTool(FabricToolTags.PICKAXES)
.sound(SoundType.GLASS)
.requiresCorrectToolForDrops()
.noCollission());
}
@Override
@ -64,56 +68,54 @@ public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeabl
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(AGE) < 2 ? Collections.emptyList()
: Lists.newArrayList(
new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED);
}
@Override
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState state = super.getPlacementState(ctx);
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx);
if (state != null) {
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return state.with(WATERLOGGED, water);
LevelReader worldView = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
boolean water = worldView.getFluidState(blockPos).getType() == Fluids.WATER;
return state.setValue(WATERLOGGED, water);
}
return null;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
}
static {
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F));
BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.125, 0.125, 0.5, 0.875F, 0.875F, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.125, 0.125, 0.0, 0.875F, 0.875F, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.5, 0.125, 0.125, 1.0, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.125, 0.125, 0.5, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F));
BOUNDING_SHAPES.put(Direction.NORTH, Shapes.box(0.125, 0.125, 0.5, 0.875F, 0.875F, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, Shapes.box(0.125, 0.125, 0.0, 0.875F, 0.875F, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, Shapes.box(0.5, 0.125, 0.125, 1.0, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.EAST, Shapes.box(0.0, 0.125, 0.125, 0.5, 0.875F, 0.875F));
}
}

View file

@ -4,14 +4,14 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.VineBlock;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.registry.EndParticles;
@ -25,7 +25,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
}
@Override
public BlockColor getBlockProvider() {
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> {
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1;
@ -54,7 +54,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@ -70,7 +70,11 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
}
static {
COLORS = new Vec3i[] { new Vec3i(250, 111, 222), new Vec3i(167, 89, 255), new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182) };
COLORS = new Vec3i[] {
new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182)
};
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
@ -19,7 +19,7 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS);
}
}

View file

@ -1,14 +1,17 @@
package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import ru.betterend.blocks.basis.BlockBase;
public class TerminiteBlock extends BlockBase {
public TerminiteBlock() {
super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708).hardness(7F).resistance(9F)
.requiresTool().sounds(SoundType.METAL));
super(FabricBlockSettings.of(Material.METAL, MaterialColor.WARPED_WART_BLOCK)
.hardness(7F)
.resistance(9F)
.requiresCorrectToolForDrops()
.sound(SoundType.METAL));
}
}

View file

@ -4,11 +4,11 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -25,25 +25,25 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock {
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockView world, BlockPos pos) {
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) {
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return world.isAir(pos.up());
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(DoublePlantBlock.TOP, true));
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.registry.EndBlocks;
@ -16,10 +15,9 @@ public class TwistedUmbrellaMossTallBlock extends DoublePlantBlock {
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
world.spawnEntity(item);
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
world.addFreshEntity(item);
}
@Override

View file

@ -4,11 +4,11 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
@ -25,25 +25,25 @@ public class UmbrellaMossBlock extends EndPlantBlock {
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockView world, BlockPos pos) {
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) {
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return world.isAir(pos.up());
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().setValue(DoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(DoublePlantBlock.TOP, true));
}
}

View file

@ -1,12 +1,11 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.registry.EndBlocks;
@ -16,10 +15,9 @@ public class UmbrellaMossTallBlock extends DoublePlantBlock {
}
@Override
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
new ItemStack(EndBlocks.UMBRELLA_MOSS));
world.spawnEntity(item);
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.UMBRELLA_MOSS));
world.addFreshEntity(item);
}
@Override

View file

@ -1,22 +1,22 @@
package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.BlockHitResult;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
@ -26,9 +26,10 @@ public class UmbrellaTreeClusterBlock extends BlockBase {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.COLOR_PURPLE)
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE)
.luminance(15));
setDefaultState(stateManager.defaultBlockState().with(NATURAL, false));
registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
}
@Override
@ -37,21 +38,18 @@ public class UmbrellaTreeClusterBlock extends BlockBase {
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
BlockHitResult hit) {
ItemStack stack = player.getMainHandStack();
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack stack = player.getMainHandItem();
if (stack.getItem() == Items.GLASS_BOTTLE) {
if (!player.isCreative()) {
stack.decrement(1);
stack.shrink(1);
}
stack = new ItemStack(EndItems.UMBRELLA_CLUSTER_JUICE);
player.giveItemStack(stack);
world.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BOTTLE_FILL,
SoundSource.BLOCKS, 1, 1, false);
BlocksHelper.setWithUpdate(world, pos,
EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.defaultBlockState().with(NATURAL, state.getValue(NATURAL)));
return ActionResult.SUCCESS;
player.addItem(stack);
world.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1, 1, false);
BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.defaultBlockState().setValue(NATURAL, state.getValue(NATURAL)));
return InteractionResult.SUCCESS;
}
return ActionResult.FAIL;
return InteractionResult.FAIL;
}
}

View file

@ -3,14 +3,14 @@ package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
@ -19,9 +19,10 @@ public class UmbrellaTreeClusterEmptyBlock extends BlockBase {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterEmptyBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.COLOR_PURPLE)
.ticksRandomly());
setDefaultState(stateManager.defaultBlockState().with(NATURAL, false));
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE)
.randomTicks());
registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
}
@Override
@ -30,10 +31,9 @@ public class UmbrellaTreeClusterEmptyBlock extends BlockBase {
}
@Override
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (state.getValue(NATURAL) && random.nextInt(16) == 0) {
BlocksHelper.setWithUpdate(world, pos,
EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().with(UmbrellaTreeClusterBlock.NATURAL, true));
BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().setValue(UmbrellaTreeClusterBlock.NATURAL, true));
}
}
}

View file

@ -9,20 +9,20 @@ import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SlimeBlock;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SlimeBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.noise.OpenSimplexNoise;
@ -40,11 +40,11 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
double px = ctx.getBlockPos().getX() * 0.1;
double py = ctx.getBlockPos().getY() * 0.1;
double pz = ctx.getBlockPos().getZ() * 0.1;
return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
double py = ctx.getClickedPos().getY() * 0.1;
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
@Override
@ -61,9 +61,9 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(COLOR) > 0) {
return Lists.newArrayList(new ItemStack(this));
} else {
return MHelper.RANDOM.nextInt(4) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.UMBRELLA_TREE_SAPLING))
: Collections.emptyList();
}
else {
return MHelper.RANDOM.nextInt(4) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.UMBRELLA_TREE_SAPLING)) : Collections.emptyList();
}
}
@ -85,15 +85,16 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
}
@Override
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) {
return state.getValue(COLOR) > 0;
}
@Environment(EnvType.CLIENT)
public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
if (state.getValue(COLOR) > 0) {
return super.isSideInvisible(state, stateFrom, direction);
} else {
return super.skipRendering(state, stateFrom, direction);
}
else {
return false;
}
}

View file

@ -1,8 +1,8 @@
package ru.betterend.blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.FeatureSaplingBlock;
import ru.betterend.client.render.ERenderLayer;
@ -20,7 +20,7 @@ public class UmbrellaTreeSaplingBlock extends FeatureSaplingBlock {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.JUNGLE_MOSS);
}

View file

@ -5,70 +5,70 @@ import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockRenderType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FluidDrainable;
import net.minecraft.world.level.block.FluidFillable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.entity.Entity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class VentBubbleColumnBlock extends Block implements FluidDrainable, FluidFillable {
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() {
super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).nonOpaque().noCollision().dropsNothing());
super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops());
}
@Override
public Fluid tryDrainFluid(LevelAccessor world, BlockPos pos, BlockState state) {
world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState(), 11);
public Fluid takeLiquid(LevelAccessor world, BlockPos pos, BlockState state) {
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
return Fluids.WATER;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.INVISIBLE;
public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos.below());
return blockState.is(this) || blockState.is(EndBlocks.HYDROTHERMAL_VENT);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return Shapes.empty();
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
if (!state.canPlaceAt(world, pos)) {
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
if (!state.canSurvive(world, pos)) {
return Blocks.WATER.defaultBlockState();
} else {
BlockPos up = pos.up();
}
else {
BlockPos up = pos.above();
if (world.getBlockState(up).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, up, this);
world.getBlockTickScheduler().schedule(up, this, 5);
world.getBlockTicks().scheduleTick(up, this, 5);
}
}
return state;
@ -80,48 +80,44 @@ public class VentBubbleColumnBlock extends Block implements FluidDrainable, Flui
double px = pos.getX() + random.nextDouble();
double py = pos.getY() + random.nextDouble();
double pz = pos.getZ() + random.nextDouble();
world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, px, py, pz, 0, 0.04, 0);
world.addAlwaysVisibleParticle(ParticleTypes.BUBBLE_COLUMN_UP, px, py, pz, 0, 0.04, 0);
}
if (random.nextInt(200) == 0) {
world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT,
SoundSource.BLOCKS, 0.2F + random.nextFloat() * 0.2F, 0.9F + random.nextFloat() * 0.15F, false);
world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BUBBLE_COLUMN_UPWARDS_AMBIENT, SoundSource.BLOCKS, 0.2F + random.nextFloat() * 0.2F, 0.9F + random.nextFloat() * 0.15F, false);
}
}
@Environment(EnvType.CLIENT)
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
BlockState blockState = world.getBlockState(pos.up());
BlockState blockState = world.getBlockState(pos.above());
if (blockState.isAir()) {
entity.onBubbleColumnSurfaceCollision(false);
entity.onAboveBubbleCol(false);
if (!world.isClientSide) {
ServerLevel serverWorld = (ServerLevel) world;
for (int i = 0; i < 2; ++i) {
serverWorld.sendParticles(ParticleTypes.SPLASH, (double) pos.getX() + world.random.nextDouble(),
(double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.0D,
0.0D, 1.0D);
serverWorld.sendParticles(ParticleTypes.BUBBLE, (double) pos.getX() + world.random.nextDouble(),
(double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.01D,
0.0D, 0.2D);
serverWorld.sendParticles(ParticleTypes.SPLASH, (double) pos.getX() + world.random.nextDouble(), (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D);
serverWorld.sendParticles(ParticleTypes.BUBBLE, (double) pos.getX() + world.random.nextDouble(), (double) (pos.getY() + 1), (double) pos.getZ() + world.random.nextDouble(), 1, 0.0D, 0.01D, 0.0D, 0.2D);
}
}
} else {
entity.onBubbleColumnCollision(false);
}
else {
entity.onInsideBubbleColumn(false);
}
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getStill(false);
return Fluids.WATER.getSource(false);
}
}

View file

@ -1,27 +1,27 @@
package ru.betterend.blocks.basis;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.BlockMirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import ru.betterend.util.BlocksHelper;
public abstract class AttachedBlock extends BlockBaseNotFull {
public static final DirectionProperty FACING = Properties.FACING;
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public AttachedBlock(net.minecraft.world.level.block.state.BlockBehaviour.Properties settings) {
public AttachedBlock(Properties settings) {
super(settings);
this.setDefaultState(this.defaultBlockState().with(FACING, Direction.UP));
this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.UP));
}
@Override
@ -30,16 +30,16 @@ public abstract class AttachedBlock extends BlockBaseNotFull {
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState blockState = this.defaultBlockState();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
LevelReader worldView = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
Direction[] directions = ctx.getNearestLookingDirections();
for (int i = 0; i < directions.length; ++i) {
Direction direction = directions[i];
Direction direction2 = direction.getOpposite();
blockState = (BlockState) blockState.with(FACING, direction2);
if (blockState.canPlaceAt(worldView, blockPos)) {
blockState = (BlockState) blockState.setValue(FACING, direction2);
if (blockState.canSurvive(worldView, blockPos)) {
return blockState;
}
}
@ -47,30 +47,30 @@ public abstract class AttachedBlock extends BlockBaseNotFull {
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction)
|| world.getBlockState(blockPos).isIn(BlockTags.LEAVES);
return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
}
else {
return state;
}
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
}

Some files were not shown because too many files have changed in this diff Show more