Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -1,38 +1,38 @@
package ru.betterend.blocks.basis;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
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.tag.BlockTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.util.BlocksHelper;
public abstract class AttachedBlock extends BlockBaseNotFull {
public static final DirectionProperty FACING = Properties.FACING;
public AttachedBlock(Settings settings) {
public AttachedBlock(Properties settings) {
super(settings);
this.setDefaultState(this.getDefaultState().with(FACING, Direction.UP));
this.setDefaultState(this.defaultBlockState().with(FACING, Direction.UP));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState = this.getDefaultState();
WorldView worldView = ctx.getWorld();
BlockState blockState = this.defaultBlockState();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
for (int i = 0; i < directions.length; ++i) {
@ -48,24 +48,24 @@ public abstract class AttachedBlock extends BlockBaseNotFull {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction) || world.getBlockState(blockPos).isIn(BlockTags.LEAVES);
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction)
|| world.getBlockState(blockPos).isIn(BlockTags.LEAVES);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}

View file

@ -2,28 +2,28 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.Patterns;
public class BarkBlock extends EndPillarBlock {
public BarkBlock(Settings settings) {
public BarkBlock(Properties settings) {
super(settings);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, getName(blockId), blockId.getPath());
}
private String getName(Identifier blockId) {
private String getName(ResourceLocation blockId) {
String name = blockId.getPath();
return name.replace("_bark", "_log_side");
}

View file

@ -3,15 +3,15 @@ package ru.betterend.blocks.basis;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.world.BlockView;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.BlockWithEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.BlockGetter;
public class BaseBlockWithEntity extends BlockWithEntity {
public BaseBlockWithEntity(Settings settings) {
public BaseBlockWithEntity(Properties settings) {
super(settings);
}
@ -19,9 +19,9 @@ public class BaseBlockWithEntity extends BlockWithEntity {
public BlockEntity createBlockEntity(BlockView world) {
return null;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
}

View file

@ -4,39 +4,39 @@ import java.io.Reader;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.Registry;
import net.minecraft.world.item.ItemStack;
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.storage.loot.LootContext;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockBase extends Block implements BlockPatterned {
public BlockBase(Settings settings) {
public BlockBase(Properties settings) {
super(settings);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState blockState, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getId(this).getPath();
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
}

View file

@ -1,13 +1,13 @@
package ru.betterend.blocks.basis;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.EntityType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
public class BlockBaseNotFull extends BlockBase {
public BlockBaseNotFull(Settings settings) {
public BlockBaseNotFull(Properties settings) {
super(settings);
}

View file

@ -7,32 +7,32 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
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.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.entity.ItemEntity;
import net.minecraft.world.entity.LivingEntity;
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.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
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.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.client.render.ERenderLayer;
@ -42,30 +42,25 @@ import ru.betterend.util.BlocksHelper;
public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
public static final IntProperty ROTATION = BlockProperties.ROTATION;
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
public static final BooleanProperty TOP = BooleanProperty.of("top");
public DoublePlantBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.noCollision());
this.setDefaultState(this.stateManager.getDefaultState().with(TOP, false));
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS)
.breakByHand(true).noCollision());
this.setDefaultState(this.stateManager.defaultBlockState().with(TOP, false));
}
public DoublePlantBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.luminance((state) -> { return state.get(TOP) ? light : 0; })
.breakByHand(true)
.noCollision());
this.setDefaultState(this.stateManager.getDefaultState().with(TOP, false));
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS)
.luminance((state) -> {
return state.getValue(TOP) ? light : 0;
}).breakByHand(true).noCollision());
this.setDefaultState(this.stateManager.defaultBlockState().with(TOP, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(TOP, ROTATION);
}
@ -82,46 +77,46 @@ public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeabl
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
BlockState up = world.getBlockState(pos.up());
return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable());
return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable());
}
public boolean canStayAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
BlockState up = world.getBlockState(pos.up());
return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getBlock() == this);
return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getBlock() == this);
}
protected boolean isTerrain(BlockState state) {
return state.isIn(EndTags.END_GROUND);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canStayAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
if (state.get(TOP)) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(TOP)) {
return Lists.newArrayList();
}
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
@ -133,20 +128,21 @@ public class DoublePlantBlock extends BlockBaseNotFull implements IRenderTypeabl
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return true;
}
@Override
public void grow(ServerWorld 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(this));
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(this));
world.spawnEntity(item);
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
int rot = world.random.nextInt(4);
BlockState bs = this.getDefaultState().with(ROTATION, rot);
BlockState bs = this.defaultBlockState().with(ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(TOP, true));
}

View file

@ -8,74 +8,74 @@ import java.util.Map;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AnvilBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.AnvilBlock;
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.material.MaterialColor;
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.Registry;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION;
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
protected final int level;
public EndAnvilBlock(MaterialColor color, int level) {
super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color));
this.level = level;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(DESTRUCTION);
}
public IntProperty getDestructionProperty() {
public IntegerProperty getDESTRUCTION() {
return DESTRUCTION;
}
public int getCraftingLevel() {
return level;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%anvil%", blockId.getPath());
map.put("%top%", getTop(blockId, block));
return Patterns.createJson(Patterns.BLOCK_ANVIL, map);
}
protected String getTop(Identifier blockId, String block) {
protected String getTop(ResourceLocation blockId, String block) {
if (block.contains("item")) {
return blockId.getPath() + "_top_0";
}
char last = block.charAt(block.length() - 1);
return blockId.getPath() + "_top_" + last;
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_ANVIL;
}
}

View file

@ -5,26 +5,26 @@ import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BarrelBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.PiglinBrain;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.level.block.BarrelBlock;
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.entity.BlockEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.mob.PiglinBrain;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
@ -41,16 +41,16 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = super.getDroppedStacks(state, builder);
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = super.getDrops(state, builder);
drop.add(new ItemStack(this.asItem()));
return drop;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (world.isClient) {
if (world.isClientSide) {
return ActionResult.SUCCESS;
} else {
BlockEntity blockEntity = world.getBlockEntity(pos);
@ -65,7 +65,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EBarrelBlockEntity) {
((EBarrelBlockEntity) blockEntity).tick();
@ -78,8 +78,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack itemStack) {
public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
if (itemStack.hasCustomName()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EBarrelBlockEntity) {
@ -87,24 +86,24 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
}
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getId(this).getPath();
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
@Override
public String getModelPattern(String block) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("open")) {
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
}
return Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_BARREL;
}
}

View file

@ -2,36 +2,38 @@ package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.PillarBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class EndBlockStripableLogLog extends EndPillarBlock {
private final Block striped;
public EndBlockStripableLogLog(MaterialColor color, Block striped) {
super(FabricBlockSettings.copyOf(striped).materialColor(color));
this.striped = striped;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (player.getMainHandStack().getItem().isIn(FabricToolTags.AXES)) {
world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isClient) {
world.setBlockState(pos, striped.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11);
world.playLocalSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlockAndUpdate(pos, striped.defaultBlockState().with(RotatedPillarBlock.AXIS,
state.getValue(RotatedPillarBlock.AXIS)), 11);
if (player != null && !player.isCreative()) {
player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player);
player.getMainHandStack().damage(1, world.random, (ServerPlayer) player);
}
}
return ActionResult.SUCCESS;

View file

@ -5,53 +5,53 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
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.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.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.Patterns;
public class EndBookshelfBlock extends BlockBase {
public EndBookshelfBlock(Block source) {
super(FabricBlockSettings.copyOf(source));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.isEffectiveOn(state)) {
int silk = EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool);
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.isCorrectToolForDrops(state)) {
int silk = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool);
if (silk > 0) {
return Collections.singletonList(new ItemStack(this));
}
}
return Collections.singletonList(new ItemStack(Items.BOOK, 3));
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, getName(blockId), blockId.getPath());
}
private String getName(Identifier blockId) {
private String getName(ResourceLocation blockId) {
String name = blockId.getPath();
return name.replace("_bookshelf", "");
}

View file

@ -5,14 +5,14 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChainBlock;
import net.minecraft.block.MaterialColor;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ChainBlock;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
@ -22,32 +22,32 @@ public class EndChainBlock extends ChainBlock implements BlockPatterned, IRender
public EndChainBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_CHAIN, blockId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_CHAIN;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;

View file

@ -4,62 +4,60 @@ import java.io.Reader;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraft.world.level.BlockGetter;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlockEntities;
public class EndChestBlock extends ChestBlock implements BlockPatterned {
private final Block parent;
public EndChestBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque(), () -> {
return EndBlockEntities.CHEST;
});
this.parent = source;
}
@Override
public BlockEntity createBlockEntity(BlockView world)
{
public BlockEntity createBlockEntity(BlockView world) {
return EndBlockEntities.CHEST.instantiate();
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder)
{
List<ItemStack> drop = super.getDroppedStacks(state, builder);
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = super.getDrops(state, builder);
drop.add(new ItemStack(this.asItem()));
return drop;
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String path) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {
return Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
}

View file

@ -5,13 +5,13 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComposterBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
@ -19,27 +19,27 @@ public class EndComposterBlock extends ComposterBlock implements BlockPatterned
public EndComposterBlock(Block source) {
super(FabricBlockSettings.copyOf(source));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this.asItem()));
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_COMPOSTER;
}
}

View file

@ -6,13 +6,13 @@ import java.util.HashMap;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CraftingTableBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
@ -22,19 +22,19 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this.asItem()));
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
@ -49,9 +49,9 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
}
});
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
}

View file

@ -8,74 +8,70 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
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.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.Item;
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.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class EndCropBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(2, 0, 2, 14, 14, 14);
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 3);
private final Block[] terrain;
private final Item drop;
public EndCropBlock(Item drop, Block... terrain) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.HOES)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.HOES).sounds(SoundType.GRASS)
.breakByHand(true).ticksRandomly().noCollision());
this.drop = drop;
this.terrain = terrain;
this.setDefaultState(getDefaultState().with(AGE, 0));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
}
@Override
protected boolean isTerrain(BlockState state) {
for (Block block: terrain) {
if (state.isOf(block)) {
for (Block block : terrain) {
if (state.is(block)) {
return true;
}
}
return false;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
if (state.get(AGE) < 3) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(AGE) < 3) {
return Collections.singletonList(new ItemStack(this));
}
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.isEffectiveOn(state)) {
int enchantment = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.isCorrectToolForDrops(state)) {
int enchantment = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
if (enchantment > 0) {
int countSeeds = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM);
int countDrops = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM);
int countSeeds = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM);
int countDrops = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
}
}
@ -83,38 +79,38 @@ public class EndCropBlock extends EndPlantBlock {
int countDrops = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
int age = state.get(AGE);
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE);
if (age < 3) {
BlocksHelper.setWithUpdate(world, pos, state.with(AGE, age + 1));
}
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return state.get(AGE) < 3;
return state.getValue(AGE) < 3;
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
return state.get(AGE) < 3;
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return state.getValue(AGE) < 3;
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state) && random.nextInt(8) == 0) {
grow(world, random, pos, state);
}
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return SHAPE;

View file

@ -1,31 +1,31 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.enums.DoubleBlockHalf;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.patterns.Patterns;
public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPatterned {
public EndDoorBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(3F, 3F).nonOpaque());
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
if (state.get(HALF) == DoubleBlockHalf.LOWER)
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(HALF) == DoubleBlockHalf.LOWER)
return Collections.singletonList(new ItemStack(this.asItem()));
else
return Collections.emptyList();
@ -35,16 +35,16 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
}
@ -59,9 +59,9 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat
}
return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_DOOR;
}
}
}

View file

@ -5,40 +5,40 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.FenceBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndFenceBlock extends FenceBlock implements BlockPatterned {
private final Block parent;
public EndFenceBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath());
}
@ -47,9 +47,9 @@ public class EndFenceBlock extends FenceBlock implements BlockPatterned {
}
return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_FENCE;
}
}

View file

@ -8,21 +8,21 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FurnaceBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.FurnaceBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.player.PlayerEntity;
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.screen.NamedScreenHandlerFactory;
import net.minecraft.stat.Stats;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -32,7 +32,7 @@ import ru.betterend.patterns.Patterns;
public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRenderTypeable {
public EndFurnaceBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance((state) -> {
return state.get(LIT) ? 13 : 0;
return state.getValue(LIT) ? 13 : 0;
}));
}
@ -40,25 +40,25 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
public BlockEntity createBlockEntity(BlockView world) {
return new EFurnaceBlockEntity();
}
@Override
protected void openScreen(World world, BlockPos pos, PlayerEntity player) {
protected void openScreen(Level world, BlockPos pos, PlayerEntity player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EFurnaceBlockEntity) {
player.openHandledScreen((NamedScreenHandlerFactory) blockEntity);
player.incrementStat(Stats.INTERACT_WITH_FURNACE);
}
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%top%", blockId.getPath() + "_top");
map.put("%side%", blockId.getPath() + "_side");
@ -66,15 +66,14 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
map.put("%front%", blockId.getPath() + "_front_on");
map.put("%glow%", blockId.getPath() + "_glow");
return Patterns.createJson(Patterns.BLOCK_FURNACE_GLOW, map);
}
else {
} else {
map.put("%front%", blockId.getPath() + "_front");
return Patterns.createJson(Patterns.BLOCK_FURNACE, map);
}
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_FURNACE;
}
@ -82,11 +81,11 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
if (blockEntity instanceof EFurnaceBlockEntity) {
EFurnaceBlockEntity entity = (EFurnaceBlockEntity) blockEntity;
for (int i = 0; i < entity.size(); i++) {

View file

@ -5,40 +5,40 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
private final Block parent;
public EndGateBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("wall")) {
if (block.contains("open")) {
return Patterns.createJson(Patterns.BLOCK_GATE_OPEN_WALL, parentId.getPath(), blockId.getPath());
@ -51,9 +51,9 @@ public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
}
return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_GATE;
}
}

View file

@ -3,27 +3,27 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.ShapeContext;
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.HorizontalFacingBlock;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
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.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Rotation;
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.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -44,13 +44,13 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING);
stateManager.add(WATERLOGGED);
}
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
switch (state.get(FACING)) {
switch (state.getValue(FACING)) {
case SOUTH:
return SOUTH_SHAPE;
case WEST:
@ -69,21 +69,21 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
return this.canPlaceOn(world, pos.offset(direction.getOpposite()), direction);
Direction direction = (Direction) state.getValue(FACING);
return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState,
WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (facing.getOpposite() == state.get(FACING) && !state.canPlaceAt(world, pos)) {
return Blocks.AIR.getDefaultState();
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (facing.getOpposite() == state.getValue(FACING) && !state.canPlaceAt(world, pos)) {
return Blocks.AIR.defaultBlockState();
} else {
if ((Boolean) state.get(WATERLOGGED)) {
if ((Boolean) state.getValue(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
return super.updateShape(state, facing, neighborState, world, pos, neighborPos);
}
}
@ -91,16 +91,16 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState2;
if (!ctx.canReplaceExisting()) {
blockState2 = ctx.getWorld().getBlockState(ctx.getBlockPos().offset(ctx.getSide().getOpposite()));
blockState2 = ctx.getLevel().getBlockState(ctx.getBlockPos().offset(ctx.getSide().getOpposite()));
if (blockState2.getBlock() == this && blockState2.get(FACING) == ctx.getSide()) {
return null;
}
}
blockState2 = this.getDefaultState();
WorldView worldView = ctx.getWorld();
blockState2 = this.defaultBlockState();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos());
Direction[] var6 = ctx.getPlacementDirections();
int var7 = var6.length;
@ -118,7 +118,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@ -129,31 +129,31 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
@Override
public FluidState getFluidState(BlockState state) {
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_LADDER;
}
}

View file

@ -1,119 +1,110 @@
package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Waterloggable;
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.FluidFillable;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
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.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
public class EndLanternBlock extends BlockBaseNotFull implements Waterloggable, FluidFillable {
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public EndLanternBlock(Block source) {
this(FabricBlockSettings.copyOf(source).luminance(15).nonOpaque());
}
public EndLanternBlock(FabricBlockSettings settings) {
super(settings.nonOpaque());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction dir = ctx.getSide();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
if (dir != Direction.DOWN && dir != Direction.UP) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
else if (dir == Direction.DOWN) {
} else if (dir == Direction.DOWN) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
else {
if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
} else {
if (sideCoversSmallSquare(worldView, blockPos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
} else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (state.get(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.down(), Direction.UP);
}
else {
if (state.getValue(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.below(), Direction.UP);
} else {
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.get(WATERLOGGED);
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
Boolean water = state.getValue(WATERLOGGED);
if (water) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
}
else {
return water ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
}
}

View file

@ -8,18 +8,18 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.MaterialColor;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
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.LeavesBlock;
import net.minecraft.world.level.material.MaterialColor;
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.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
@ -28,61 +28,60 @@ import ru.betterend.util.MHelper;
public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRenderTypeable {
private final Block sapling;
public EndLeavesBlock(Block sapling, MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.allowsSpawning((state, world, pos, type) -> { return false; })
.suffocates((state, world, pos) -> { return false; })
.blockVision((state, world, pos) -> { return false; })
.materialColor(color)
.breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true));
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).allowsSpawning((state, world, pos, type) -> {
return false;
}).suffocates((state, world, pos) -> {
return false;
}).blockVision((state, world, pos) -> {
return false;
}).materialColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true));
this.sapling = sapling;
}
public EndLeavesBlock(Block sapling, MaterialColor color, int light) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.allowsSpawning((state, world, pos, type) -> { return false; })
.suffocates((state, world, pos) -> { return false; })
.blockVision((state, world, pos) -> { return false; })
.materialColor(color)
.luminance(light)
.breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS));
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).allowsSpawning((state, world, pos, type) -> {
return false;
}).suffocates((state, world, pos) -> {
return false;
}).blockVision((state, world, pos) -> {
return false;
}).materialColor(color).luminance(light).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS));
this.sapling = sapling;
}
@Override
public String getStatesPattern(Reader data) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, blockId, blockId);
}
@Override
public String getModelPattern(String block) {
String blockId = Registry.BLOCK.getId(this).getPath();
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null) {
if (tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool.getItem().isIn(FabricToolTags.SHEARS)
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Collections.singletonList(new ItemStack(this));
}
int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
if (MHelper.RANDOM.nextInt(16) <= fortune) {
return Lists.newArrayList(new ItemStack(sapling));
}

View file

@ -7,14 +7,14 @@ import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PaneBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.PaneBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
@ -26,30 +26,29 @@ public class EndMetalPaneBlock extends PaneBlock implements BlockPatterned, IRen
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
}
if (block.contains("post")) {
return Patterns.createJson(Patterns.BLOCK_BARS_POST, blockId.getPath(), blockId.getPath());
}
else {
} else {
return Patterns.createJson(Patterns.BLOCK_BARS_SIDE, blockId.getPath(), blockId.getPath());
}
}
@Environment(EnvType.CLIENT)
public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {
if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) {
@ -57,12 +56,12 @@ public class EndMetalPaneBlock extends PaneBlock implements BlockPatterned, IRen
}
return super.isSideInvisible(state, stateFrom, direction);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_BARS;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;

View file

@ -5,48 +5,48 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.WeightedPressurePlateBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockPatterned {
private final Block parent;
public EndMetalPlateBlock(Block source) {
super(15, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().requiresTool().strength(0.5F));
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_PLATE;
}
}

View file

@ -6,20 +6,20 @@ import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.OreBlock;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry;
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.OreBlock;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.Item;
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 net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.util.MHelper;
@ -29,36 +29,33 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
private final int minCount;
private final int maxCount;
private final int expirience;
public EndOreBlock(Item drop, int minCount, int maxCount, int expirience) {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
.hardness(3F)
.resistance(9F)
.requiresTool()
.sounds(BlockSoundGroup.STONE));
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND).hardness(3F).resistance(9F).requiresTool()
.sounds(SoundType.STONE));
this.dropItem = drop;
this.minCount = minCount;
this.maxCount = maxCount;
this.expirience = expirience;
}
@Override
protected int getExperienceWhenMined(Random random) {
return this.expirience > 0 ? random.nextInt(expirience) + 1 : 0;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.isEffectiveOn(state)) {
if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.isCorrectToolForDrops(state)) {
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Collections.singletonList(new ItemStack(this));
}
int count = 0;
int enchantment = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
int enchantment = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
if (enchantment > 0) {
int min = MathHelper.clamp(minCount + enchantment, minCount, maxCount);
int max = maxCount + (enchantment / Enchantments.FORTUNE.getMaxLevel());
int min = Mth.clamp(minCount + enchantment, minCount, maxCount);
int max = maxCount + (enchantment / Enchantments.BLOCK_FORTUNE.getMaxLevel());
if (min == max) {
return Collections.singletonList(new ItemStack(dropItem, max));
}
@ -70,21 +67,21 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
}
return Collections.emptyList();
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getId(this).getPath();
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
}

View file

@ -5,44 +5,44 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndPillarBlock extends PillarBlock implements BlockPatterned {
public EndPillarBlock(Settings settings) {
public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned {
public EndPillarBlock(Properties settings) {
super(settings);
}
public EndPillarBlock(Block block) {
super(FabricBlockSettings.copyOf(block));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, texture, texture);
}
@Override
public String getModelPattern(String block) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_PILLAR;
}
}

View file

@ -7,28 +7,28 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.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.entity.ItemEntity;
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.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -36,33 +36,27 @@ import ru.betterend.registry.EndTags;
public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
public EndPlantBlock() {
this(false);
}
public EndPlantBlock(int light) {
this(false, light);
}
public EndPlantBlock(boolean replaceable) {
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.noCollision());
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true).noCollision());
}
public EndPlantBlock(boolean replaceable, int light) {
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.luminance(light)
.breakByHand(true)
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).luminance(light).breakByHand(true)
.noCollision());
}
public EndPlantBlock(Settings settings) {
public EndPlantBlock(Properties settings) {
super(settings);
}
@ -79,35 +73,35 @@ public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable,
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
return isTerrain(down);
}
protected boolean isTerrain(BlockState state) {
return state.isIn(EndTags.END_GROUND);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
@ -119,13 +113,14 @@ public class EndPlantBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return true;
}
@Override
public void grow(ServerWorld 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(this));
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(this));
world.spawnEntity(item);
}
}

View file

@ -4,59 +4,54 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
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.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
import ru.betterend.blocks.BlockProperties;
public abstract class EndPlantWithAgeBlock extends EndPlantBlock {
public static final IntProperty AGE = BlockProperties.AGE;
public static final IntegerProperty AGE = BlockProperties.AGE;
public EndPlantWithAgeBlock() {
this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.breakByHand(true).ticksRandomly().noCollision());
}
public EndPlantWithAgeBlock(FabricBlockSettings settings) {
super(settings);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
}
public abstract void growAdult(StructureWorldAccess world, Random random, BlockPos pos);
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
int age = state.get(AGE);
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
}
else {
world.setBlockAndUpdate(pos, state.with(AGE, age + 1));
} else {
growAdult(world, random, pos);
}
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return true;
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (random.nextInt(8) == 0) {
grow(world, random, pos, state);

View file

@ -5,48 +5,48 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PressurePlateBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.PressurePlateBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned {
private final Block parent;
public EndPlateBlock(ActivationRule rule, Block source) {
super(rule, FabricBlockSettings.copyOf(source).noCollision().nonOpaque().strength(0.5F));
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return this.stateManager.getProperty("facing") != null ? Patterns.STATE_PLATE_ROTATED : Patterns.STATE_PLATE;
}
}

View file

@ -5,38 +5,38 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.level.block.AbstractSignBlock;
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.world.entity.LivingEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.state.StateManager;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Identifier;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.SignType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.entities.ESignBlockEntity;
import ru.betterend.interfaces.ISpetialItem;
@ -45,86 +45,84 @@ import ru.betterend.patterns.Patterns;
import ru.betterend.util.BlocksHelper;
public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, ISpetialItem {
public static final IntProperty ROTATION = Properties.ROTATION;
public static final IntegerProperty ROTATION = Properties.ROTATION;
public static final BooleanProperty FLOOR = BooleanProperty.of("floor");
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
Block.createCuboidShape(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D),
Block.createCuboidShape(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D),
Block.createCuboidShape(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D),
Block.createCuboidShape(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)
};
Block.createCuboidShape(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D),
Block.createCuboidShape(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D),
Block.createCuboidShape(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D),
Block.createCuboidShape(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D) };
private final Block parent;
public EndSignBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollision().nonOpaque(), SignType.OAK);
this.setDefaultState(this.stateManager.getDefaultState().with(ROTATION, 0).with(FLOOR, false).with(WATERLOGGED, false));
this.setDefaultState(
this.stateManager.defaultBlockState().with(ROTATION, 0).with(FLOOR, false).with(WATERLOGGED, false));
this.parent = source;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(ROTATION, FLOOR, WATERLOGGED);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return state.get(FLOOR) ? SHAPE : WALL_SHAPES[state.get(ROTATION) >> 2];
return state.getValue(FLOOR) ? SHAPE : WALL_SHAPES[state.getValue(ROTATION) >> 2];
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new ESignBlockEntity();
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
if (placer != null && placer instanceof PlayerEntity) {
ESignBlockEntity sign = (ESignBlockEntity) world.getBlockEntity(pos);
if (!world.isClient) {
if (!world.isClientSide) {
sign.setEditor((PlayerEntity) placer);
((ServerPlayerEntity) placer).networkHandler.sendPacket(new SignEditorOpenS2CPacket(pos));
}
else {
((ServerPlayer) placer).networkHandler.sendPacket(new SignEditorOpenS2CPacket(pos));
} else {
sign.setEditable(true);
}
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if ((Boolean) state.get(WATERLOGGED)) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if ((Boolean) state.getValue(WATERLOGGED)) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return state.get(WATERLOGGED) ? state.getFluidState().getBlockState() : Blocks.AIR.getDefaultState();
return state.getValue(WATERLOGGED) ? state.getFluidState().getBlockState() : Blocks.AIR.defaultBlockState();
}
return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
return super.updateShape(state, facing, neighborState, world, pos, neighborPos);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (!state.get(FLOOR)) {
int index = (((state.get(ROTATION) >> 2) + 2)) & 3;
return world.getBlockState(pos.offset(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid();
}
else {
return world.getBlockState(pos.down()).getMaterial().isSolid();
if (!state.getValue(FLOOR)) {
int index = (((state.getValue(ROTATION) >> 2) + 2)) & 3;
return world.getBlockState(pos.relative(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid();
} else {
return world.getBlockState(pos.below()).getMaterial().isSolid();
}
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
if (ctx.getSide() == Direction.UP) {
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
return this.getDefaultState().with(FLOOR, true)
.with(ROTATION, MathHelper.floor((180.0 + ctx.getPlayerYaw() * 16.0 / 360.0) + 0.5 - 12) & 15)
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos());
return this.defaultBlockState().with(FLOOR, true)
.with(ROTATION, Mth.floor((180.0 + ctx.getPlayerYaw() * 16.0 / 360.0) + 0.5 - 12) & 15)
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
}
else if (ctx.getSide() != Direction.DOWN) {
BlockState blockState = this.getDefaultState();
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
WorldView worldView = ctx.getWorld();
} else if (ctx.getSide() != Direction.DOWN) {
BlockState blockState = this.defaultBlockState();
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getBlockPos());
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
@ -132,7 +130,7 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I
Direction direction = directions[i];
if (direction.getAxis().isHorizontal()) {
Direction dir = direction.getOpposite();
int rot = MathHelper.floor((180.0 + dir.asRotation() * 16.0 / 360.0) + 0.5 + 4) & 15;
int rot = Mth.floor((180.0 + dir.asRotation() * 16.0 / 360.0) + 0.5 + 4) & 15;
blockState = blockState.with(ROTATION, rot);
if (blockState.canPlaceAt(worldView, blockPos)) {
return blockState.with(FLOOR, false).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
@ -143,45 +141,45 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I
return null;
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String path) {
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, path);
}
return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return (BlockState) state.with(ROTATION, rotation.rotate((Integer) state.get(ROTATION), 16));
public BlockState rotate(BlockState state, Rotation rotation) {
return (BlockState) state.with(ROTATION, rotation.rotate((Integer) state.getValue(ROTATION), 16));
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return (BlockState) state.with(ROTATION, mirror.mirror((Integer) state.get(ROTATION), 16));
return (BlockState) state.with(ROTATION, mirror.mirror((Integer) state.getValue(ROTATION), 16));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public Fluid tryDrainFluid(WorldAccess world, BlockPos pos, BlockState state) {
public Fluid tryDrainFluid(LevelAccessor world, BlockPos pos, BlockState state) {
// TODO Auto-generated method stub
return null;
}
@ -193,7 +191,7 @@ public class EndSignBlock extends AbstractSignBlock implements BlockPatterned, I
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
// TODO Auto-generated method stub
return false;
}

View file

@ -5,45 +5,45 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SlabBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndSlabBlock extends SlabBlock implements BlockPatterned {
private final Block parent;
public EndSlabBlock(Block source) {
super(FabricBlockSettings.copyOf(source));
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SLAB;
}
}

View file

@ -5,41 +5,42 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
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.StairsBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndStairsBlock extends StairsBlock implements BlockPatterned {
private final Block parent;
public EndStairsBlock(Block source) {
super(source.getDefaultState(), FabricBlockSettings.copyOf(source));
super(source.defaultBlockState(), FabricBlockSettings.copyOf(source));
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("inner")) {
return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
}
@ -48,9 +49,9 @@ public class EndStairsBlock extends StairsBlock implements BlockPatterned {
}
return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_STAIRS;
}
}

View file

@ -5,40 +5,40 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StoneButtonBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.StoneButtonBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatterned {
private final Block parent;
public EndStoneButtonBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
}
@ -47,9 +47,9 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatter
}
return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_BUTTON;
}
}

View file

@ -1,6 +1,6 @@
package ru.betterend.blocks.basis;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
public class EndStonelateBlock extends EndPlateBlock {
public EndStonelateBlock(Block source) {

View file

@ -6,13 +6,13 @@ import java.util.HashMap;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.TrapdoorBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
@ -24,24 +24,24 @@ public class EndTrapdoorBlock extends TrapdoorBlock implements IRenderTypeable,
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getId(this).getPath();
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String name = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
@ -51,9 +51,9 @@ public class EndTrapdoorBlock extends TrapdoorBlock implements IRenderTypeable,
}
});
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_TRAPDOOR;
}
}

View file

@ -2,56 +2,49 @@ package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material;
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.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
public class EndUnderwaterWallPlantBlock extends EndWallPlantBlock implements FluidFillable {
public EndUnderwaterWallPlantBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).breakByHand(true).noCollision());
}
public EndUnderwaterWallPlantBlock(int light) {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.luminance(light)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).luminance(light).breakByHand(true).noCollision());
}
public EndUnderwaterWallPlantBlock(Settings settings) {
public EndUnderwaterWallPlantBlock(Properties settings) {
super(settings);
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getStill(false);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getFluidState(pos).getFluid() == Fluids.WATER && super.canPlaceAt(state, world, pos);

View file

@ -5,41 +5,41 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.WallBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.WallBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndWallBlock extends WallBlock implements BlockPatterned {
private final Block parent;
public EndWallBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_WALL, parentId.getPath(), blockId.getPath());
}
@ -51,9 +51,9 @@ public class EndWallBlock extends WallBlock implements BlockPatterned {
}
return Patterns.createJson(Patterns.BLOCK_WALL_POST, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_WALL;
}
}

View file

@ -7,64 +7,56 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
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.block.HorizontalFacingBlock;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.ShapeContext;
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.DirectionProperty;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.util.BlocksHelper;
public class EndWallPlantBlock extends EndPlantBlock {
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(
Direction.NORTH, Block.createCuboidShape(1, 1, 8, 15, 15, 16),
Direction.SOUTH, Block.createCuboidShape(1, 1, 0, 15, 15, 8),
Direction.WEST, Block.createCuboidShape(8, 1, 1, 16, 15, 15),
Direction.EAST, Block.createCuboidShape(0, 1, 1, 8, 15, 15)));
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(Direction.NORTH,
Block.createCuboidShape(1, 1, 8, 15, 15, 16), Direction.SOUTH, Block.createCuboidShape(1, 1, 0, 15, 15, 8),
Direction.WEST, Block.createCuboidShape(8, 1, 1, 16, 15, 15), Direction.EAST,
Block.createCuboidShape(0, 1, 1, 8, 15, 15)));
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public EndWallPlantBlock() {
this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.noCollision());
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.breakByHand(true).noCollision());
}
public EndWallPlantBlock(int light) {
this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.luminance(light)
.breakByHand(true)
.noCollision());
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.luminance(light).breakByHand(true).noCollision());
}
public EndWallPlantBlock(Settings settings) {
public EndWallPlantBlock(Properties settings) {
super(settings);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return SHAPES.get(state.get(FACING));
return SHAPES.get(state.getValue(FACING));
}
@Override
@ -74,20 +66,20 @@ public class EndWallPlantBlock extends EndPlantBlock {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
BlockState blockState = world.getBlockState(blockPos);
return isSupport(world, blockPos, blockState, direction);
}
public boolean isSupport(WorldView world, BlockPos pos, BlockState blockState, Direction direction) {
return blockState.getMaterial().isSolid() && blockState.isSideSolidFullSquare(world, pos, direction);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState = this.getDefaultState();
WorldView worldView = ctx.getWorld();
BlockState blockState = this.defaultBlockState();
WorldView worldView = ctx.getLevel();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
for (int i = 0; i < directions.length; ++i) {
@ -104,17 +96,17 @@ public class EndWallPlantBlock extends EndPlantBlock {
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}

View file

@ -5,40 +5,40 @@ import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.WoodenButtonBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.WoodenButtonBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndWoodenButtonBlock extends WoodenButtonBlock implements BlockPatterned {
private final Block parent;
public EndWoodenButtonBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(0.5F, 0.5F).nonOpaque());
this.parent = source;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
}
@ -47,9 +47,9 @@ public class EndWoodenButtonBlock extends WoodenButtonBlock implements BlockPatt
}
return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_BUTTON;
}
}

View file

@ -1,6 +1,6 @@
package ru.betterend.blocks.basis;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
public class EndWoodenPlateBlock extends EndPlateBlock {
public EndWoodenPlateBlock(Block source) {

View file

@ -4,22 +4,22 @@ import java.io.Reader;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
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.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
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.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
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.gen.feature.Feature;
import ru.betterend.client.render.ERenderLayer;
@ -29,26 +29,17 @@ import ru.betterend.registry.EndTags;
public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
public FeatureSaplingBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.breakInstantly()
.sounds(BlockSoundGroup.GRASS)
.ticksRandomly());
super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly()
.sounds(SoundType.GRASS).ticksRandomly());
}
public FeatureSaplingBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.breakInstantly()
.sounds(BlockSoundGroup.GRASS)
.luminance(light)
.ticksRandomly());
super(FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).breakInstantly()
.sounds(SoundType.GRASS).luminance(light).ticksRandomly());
}
protected abstract Feature<?> getFeature();
@Override
@ -58,13 +49,14 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos))
return Blocks.AIR.getDefaultState();
return Blocks.AIR.defaultBlockState();
else
return state;
}
@ -75,34 +67,34 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0;
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null);
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
if (block.contains("item")) {
@ -111,9 +103,9 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Fe
}
return Patterns.createJson(Patterns.BLOCK_CROSS, block);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SAPLING;
}
}

View file

@ -8,21 +8,21 @@ 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.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemConvertible;
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 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.BlockView;
import net.minecraft.world.level.BlockGetter;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.MHelper;
@ -31,52 +31,44 @@ public class FurBlock extends AttachedBlock implements IRenderTypeable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
private final ItemConvertible drop;
private final int dropChance;
public FurBlock(ItemConvertible drop, int light, int dropChance, boolean wet) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(wet ? BlockSoundGroup.WET_GRASS : BlockSoundGroup.GRASS)
.luminance(light)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(wet ? SoundType.WET_GRASS : SoundType.GRASS).luminance(light).breakByHand(true).noCollision());
this.drop = drop;
this.dropChance = dropChance;
}
public FurBlock(ItemConvertible drop, int dropChance) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.GRASS).breakByHand(true).noCollision());
this.drop = drop;
this.dropChance = dropChance;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return BOUNDING_SHAPES.get(state.get(FACING));
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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) {
return Lists.newArrayList(new ItemStack(this));
}
else if (dropChance < 1 || MHelper.RANDOM.nextInt(dropChance) == 0) {
} else if (dropChance < 1 || MHelper.RANDOM.nextInt(dropChance) == 0) {
return Lists.newArrayList(new ItemStack(drop));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
static {
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));

View file

@ -11,33 +11,33 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.state.StateManager;
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.ShapeContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.player.PlayerEntity;
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.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.tag.BlockTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
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.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.PedestalState;
import ru.betterend.blocks.InfusionPedestal;
@ -50,14 +50,14 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
public final static EnumProperty<PedestalState> STATE = BlockProperties.PEDESTAL_STATE;
public static final BooleanProperty HAS_ITEM = BlockProperties.HAS_ITEM;
public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT;
private static final VoxelShape SHAPE_DEFAULT;
private static final VoxelShape SHAPE_COLUMN;
private static final VoxelShape SHAPE_PILLAR;
private static final VoxelShape SHAPE_PEDESTAL_TOP;
private static final VoxelShape SHAPE_COLUMN_TOP;
private static final VoxelShape SHAPE_BOTTOM;
/**
*
* Register new Pedestal block with Better End mod id.
@ -69,7 +69,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
public static Block registerPedestal(String name, Block source) {
return EndBlocks.registerBlock(name, new PedestalBlock(source));
}
/**
*
* Register new Pedestal block with specified mod id.
@ -78,29 +78,32 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
* @param source
* @return new Pedestal block with specified id.
*/
public static Block registerPedestal(Identifier id, Block source) {
public static Block registerPedestal(ResourceLocation id, Block source) {
return EndBlocks.registerBlock(id, new PedestalBlock(source));
}
protected final Block parent;
protected float height = 1.0F;
public PedestalBlock(Block parent) {
super(FabricBlockSettings.copyOf(parent).luminance(state -> state.get(HAS_LIGHT) ? 12 : 0));
this.setDefaultState(stateManager.getDefaultState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false).with(HAS_LIGHT, false));
super(FabricBlockSettings.copyOf(parent).luminance(state -> state.getValue(HAS_LIGHT) ? 12 : 0));
this.setDefaultState(stateManager.defaultBlockState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false)
.with(HAS_LIGHT, false));
this.parent = parent;
}
public float getHeight(BlockState state) {
if (state.getBlock() instanceof PedestalBlock && state.get(STATE) == PedestalState.PEDESTAL_TOP) {
if (state.getBlock() instanceof PedestalBlock && state.getValue(STATE) == PedestalState.PEDESTAL_TOP) {
return this.height - 0.2F;
}
return this.height;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME;
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (world.isClientSide || !state.is(this))
return ActionResult.CONSUME;
if (!isPlaceable(state)) {
return ActionResult.PASS;
}
@ -109,7 +112,8 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (pedestal.isEmpty()) {
ItemStack itemStack = player.getStackInHand(hand);
if (itemStack.isEmpty()) return ActionResult.CONSUME;
if (itemStack.isEmpty())
return ActionResult.CONSUME;
pedestal.setStack(0, itemStack.split(1));
checkRitual(world, pos);
return ActionResult.SUCCESS;
@ -125,10 +129,10 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
return ActionResult.PASS;
}
public void checkRitual(World world, BlockPos pos) {
Mutable posMutable = new Mutable();
for (Point point: InfusionRitual.getMap()) {
public void checkRitual(Level world, BlockPos pos) {
MutableBlockPos posMutable = new MutableBlockPos();
for (Point point : InfusionRitual.getMap()) {
posMutable.set(pos).move(point.x, 0, point.y);
BlockState state = world.getBlockState(posMutable);
if (state.getBlock() instanceof InfusionPedestal) {
@ -137,15 +141,16 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
}
}
@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext context) {
World world = context.getWorld();
Level world = context.getLevel();
BlockPos pos = context.getBlockPos();
BlockState upState = world.getBlockState(pos.up());
BlockState downState = world.getBlockState(pos.down());
boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) || upState.isIn(BlockTags.WALLS);
BlockState downState = world.getBlockState(pos.below());
boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN)
|| upState.isIn(BlockTags.WALLS);
boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock;
boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
@ -161,27 +166,34 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
return getDefaultState();
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
BlockState updated = getUpdatedState(state, direction, newState, world, pos, posFrom);
if (!updated.isOf(this)) return updated;
if (!updated.is(this))
return updated;
if (!isPlaceable(updated)) {
moveStoredStack(world, updated, pos);
}
return updated;
}
private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
if (!state.isOf(this)) return state.getStateForNeighborUpdate(direction, newState, world, pos, posFrom);
if (direction != Direction.UP && direction != Direction.DOWN) return state;
private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
BlockPos pos, BlockPos posFrom) {
if (!state.is(this))
return state.updateShape(direction, newState, world, pos, posFrom);
if (direction != Direction.UP && direction != Direction.DOWN)
return state;
BlockState upState = world.getBlockState(pos.up());
BlockState downState = world.getBlockState(pos.down());
boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN) || upState.isIn(BlockTags.WALLS);
BlockState downState = world.getBlockState(pos.below());
boolean upSideSolid = upState.isSideSolidFullSquare(world, pos.up(), Direction.DOWN)
|| upState.isIn(BlockTags.WALLS);
boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock;
boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock;
if (direction == Direction.UP) {
upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN) || newState.isIn(BlockTags.WALLS);
upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN)
|| newState.isIn(BlockTags.WALLS);
hasPedestalOver = newState.getBlock() instanceof PedestalBlock;
} else {
hasPedestalUnder = newState.getBlock() instanceof PedestalBlock;
@ -205,13 +217,13 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
return updatedState;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(super.getDroppedStacks(state, builder));
if (state.isOf(this)) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(super.getDrops(state, builder));
if (state.is(this)) {
if (isPlaceable(state)) {
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
if (blockEntity instanceof PedestalBlockEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (!pedestal.isEmpty()) {
@ -224,10 +236,10 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
return drop;
}
private void moveStoredStack(WorldAccess world, BlockState state, BlockPos pos) {
private void moveStoredStack(LevelAccessor world, BlockState state, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof PedestalBlockEntity && state.isOf(this)) {
if (blockEntity instanceof PedestalBlockEntity && state.is(this)) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
ItemStack stack = pedestal.removeStack(0);
if (!stack.isEmpty()) {
@ -235,12 +247,12 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
}
}
private void moveStoredStack(BlockEntity blockEntity, WorldAccess world, ItemStack stack, BlockPos pos) {
private void moveStoredStack(BlockEntity blockEntity, LevelAccessor world, ItemStack stack, BlockPos pos) {
BlockState state = world.getBlockState(pos);
if (!state.isOf(this)) {
if (!state.is(this)) {
dropStoredStack(blockEntity, stack, pos);
} else if (state.get(STATE).equals(PedestalState.PILLAR)) {
} else if (state.getValue(STATE).equals(PedestalState.PILLAR)) {
moveStoredStack(blockEntity, world, stack, pos.up());
} else if (!isPlaceable(state)) {
dropStoredStack(blockEntity, stack, pos);
@ -255,15 +267,15 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
dropStoredStack(blockEntity, stack, pos);
}
}
private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) {
if (blockEntity != null && blockEntity.getWorld() != null) {
World world = blockEntity.getWorld();
if (blockEntity != null && blockEntity.getLevel() != null) {
Level world = blockEntity.getLevel();
Block.dropStack(world, getDropPos(world, pos), stack);
}
}
private BlockPos getDropPos(WorldAccess world, BlockPos pos) {
private BlockPos getDropPos(LevelAccessor world, BlockPos pos) {
BlockPos dropPos;
if (world.getBlockState(pos).isAir()) {
return pos;
@ -271,51 +283,51 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
if (world.getBlockState(pos.up()).isAir()) {
return pos.up();
}
for(int i = 2; i < Direction.values().length; i++) {
dropPos = pos.offset(Direction.byId(i));
for (int i = 2; i < Direction.values().length; i++) {
dropPos = pos.relative(Direction.byId(i));
if (world.getBlockState(dropPos).isAir()) {
return dropPos.toImmutable();
}
}
return getDropPos(world, pos.up());
}
public boolean isPlaceable(BlockState state) {
if (!state.isOf(this)) return false;
PedestalState currentState = state.get(STATE);
return currentState == PedestalState.DEFAULT ||
currentState == PedestalState.PEDESTAL_TOP;
if (!state.is(this))
return false;
PedestalState currentState = state.getValue(STATE);
return currentState == PedestalState.DEFAULT || currentState == PedestalState.PEDESTAL_TOP;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (state.isOf(this)) {
switch(state.get(STATE)) {
case BOTTOM: {
return SHAPE_BOTTOM;
}
case PEDESTAL_TOP: {
return SHAPE_PEDESTAL_TOP;
}
case COLUMN_TOP: {
return SHAPE_COLUMN_TOP;
}
case PILLAR: {
return SHAPE_PILLAR;
}
case COLUMN: {
return SHAPE_COLUMN;
}
default: {
return SHAPE_DEFAULT;
}
if (state.is(this)) {
switch (state.getValue(STATE)) {
case BOTTOM: {
return SHAPE_BOTTOM;
}
case PEDESTAL_TOP: {
return SHAPE_PEDESTAL_TOP;
}
case COLUMN_TOP: {
return SHAPE_COLUMN_TOP;
}
case PILLAR: {
return SHAPE_PILLAR;
}
case COLUMN: {
return SHAPE_COLUMN;
}
default: {
return SHAPE_DEFAULT;
}
}
}
return super.getOutlineShape(state, world, pos, context);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(STATE, HAS_ITEM, HAS_LIGHT);
}
@ -323,31 +335,31 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
public BlockEntity createBlockEntity(BlockView world) {
return new PedestalBlockEntity();
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return state.getBlock() instanceof PedestalBlock;
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return state.get(HAS_ITEM) ? 15 : 0;
public int getComparatorOutput(BlockState state, Level world, BlockPos pos) {
return state.getValue(HAS_ITEM) ? 15 : 0;
}
@Override
public String getStatesPattern(Reader data) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, texture, texture);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(parent);
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
String name = blockId.getPath();
Map<String, String> textures = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%mod%", blockId.getNamespace() );
put("%mod%", blockId.getNamespace());
put("%top%", name + "_top");
put("%base%", name + "_base");
put("%pillar%", name + "_pillar");
@ -367,12 +379,12 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
}
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_PEDESTAL;
}
static {
VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16);

View file

@ -3,53 +3,52 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.Patterns;
public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeable {
public SimpleLeavesBlock(MaterialColor color) {
super(FabricBlockSettings.of(Material.LEAVES)
.strength(0.2F)
.sounds(BlockSoundGroup.GRASS)
.nonOpaque()
.allowsSpawning((state, world, pos, type) -> { return false; })
.suffocates((state, world, pos) -> { return false; })
.blockVision((state, world, pos) -> { return false; })
.materialColor(color));
super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).sounds(SoundType.GRASS).nonOpaque()
.allowsSpawning((state, world, pos, type) -> {
return false;
}).suffocates((state, world, pos) -> {
return false;
}).blockVision((state, world, pos) -> {
return false;
}).materialColor(color));
}
public SimpleLeavesBlock(MaterialColor color, int light) {
super(FabricBlockSettings.of(Material.LEAVES)
.strength(0.2F)
.sounds(BlockSoundGroup.GRASS)
.nonOpaque()
.luminance(light)
.allowsSpawning((state, world, pos, type) -> { return false; })
.suffocates((state, world, pos) -> { return false; })
.blockVision((state, world, pos) -> { return false; })
.materialColor(color));
super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).sounds(SoundType.GRASS).nonOpaque()
.luminance(light).allowsSpawning((state, world, pos, type) -> {
return false;
}).suffocates((state, world, pos) -> {
return false;
}).blockVision((state, world, pos) -> {
return false;
}).materialColor(color));
}
@Override
public String getStatesPattern(Reader data) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, texture, texture);
}
@Override
public String getModelPattern(String block) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_SIMPLE;
}

View file

@ -1,32 +1,32 @@
package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.entity.LivingEntity;
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.FluidFillable;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.world.level.block.Waterloggable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.client.render.ERenderLayer;
@ -36,86 +36,81 @@ import ru.betterend.patterns.Patterns;
public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable, FluidFillable, IRenderTypeable {
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
public static final IntProperty SIZE = BlockProperties.SIZE;
public static final IntegerProperty SIZE = BlockProperties.SIZE;
private static final VoxelShape[] SHAPES;
public StalactiteBlock(Block source) {
super(FabricBlockSettings.copy(source).nonOpaque());
this.setDefaultState(getStateManager().getDefaultState().with(SIZE, 0).with(IS_FLOOR, true).with(WATERLOGGED, false));
this.setDefaultState(
getStateManager().defaultBlockState().with(SIZE, 0).with(IS_FLOOR, true).with(WATERLOGGED, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(WATERLOGGED, IS_FLOOR, SIZE);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return SHAPES[state.get(SIZE)];
return SHAPES[state.getValue(SIZE)];
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView world = ctx.getWorld();
WorldView world = ctx.getLevel();
BlockPos pos = ctx.getBlockPos();
Direction dir = ctx.getSide();
boolean water = world.getFluidState(pos).getFluid() == Fluids.WATER;
if (dir == Direction.DOWN) {
if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (isThis(world, pos.down()) || sideCoversSmallSquare(world, pos.down(), Direction.UP)) {
} else if (isThis(world, pos.below()) || sideCoversSmallSquare(world, pos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
else {
if (isThis(world, pos.down()) || sideCoversSmallSquare(world, pos.down(), Direction.UP)) {
} else {
if (isThis(world, pos.below()) || sideCoversSmallSquare(world, pos.below(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) {
} else if (isThis(world, pos.up()) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else {
} else {
return null;
}
}
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
boolean hasUp = isThis(world, pos.up());
boolean hasDown = isThis(world, pos.down());
Mutable mut = new Mutable();
boolean hasDown = isThis(world, pos.below());
MutableBlockPos mut = new MutableBlockPos();
if (hasUp && hasDown) {
boolean floor = state.get(IS_FLOOR);
BlockPos second = floor ? pos.up() : pos.down();
boolean floor = state.getValue(IS_FLOOR);
BlockPos second = floor ? pos.up() : pos.below();
BlockState bState = world.getBlockState(second);
world.setBlockState(pos, state.with(SIZE, 1).with(IS_FLOOR, floor));
world.setBlockState(second, bState.with(SIZE, 1).with(IS_FLOOR, !floor));
world.setBlockAndUpdate(pos, state.with(SIZE, 1).with(IS_FLOOR, floor));
world.setBlockAndUpdate(second, bState.with(SIZE, 1).with(IS_FLOOR, !floor));
bState = state;
int startSize = floor ? 1 : 2;
mut.set(pos.getX(), pos.getY() + 1, pos.getZ());
for (int i = 0; i < 8 && isThis(bState); i++) {
world.setBlockState(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, false));
world.setBlockAndUpdate(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, false));
mut.setY(mut.getY() + 1);
bState = world.getBlockState(mut);
}
bState = state;
startSize = floor ? 2 : 1;
mut.set(pos.getX(), pos.getY() - 1, pos.getZ());
for (int i = 0; i < 8 && isThis(bState); i++) {
world.setBlockState(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, true));
world.setBlockAndUpdate(mut, bState.with(SIZE, startSize++).with(IS_FLOOR, true));
mut.setY(mut.getY() - 1);
bState = world.getBlockState(mut);
}
}
else if (hasDown) {
} else if (hasDown) {
mut.setX(pos.getX());
mut.setZ(pos.getZ());
for (int i = 1; i < 8; i++) {
@ -124,18 +119,15 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable,
BlockState state2 = world.getBlockState(mut);
int size = state2.get(SIZE);
if (size < i) {
world.setBlockState(mut, state2.with(SIZE, i).with(IS_FLOOR, true));
}
else {
world.setBlockAndUpdate(mut, state2.with(SIZE, i).with(IS_FLOOR, true));
} else {
break;
}
}
else {
} else {
break;
}
}
}
else if (hasUp) {
} else if (hasUp) {
mut.setX(pos.getX());
mut.setZ(pos.getZ());
for (int i = 1; i < 8; i++) {
@ -144,80 +136,79 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable,
BlockState state2 = world.getBlockState(mut);
int size = state2.get(SIZE);
if (size < i) {
world.setBlockState(mut, state2.with(SIZE, i).with(IS_FLOOR, false));
}
else {
world.setBlockAndUpdate(mut, state2.with(SIZE, i).with(IS_FLOOR, false));
} else {
break;
}
}
else {
} else {
break;
}
}
}
}
private boolean isThis(WorldView world, BlockPos pos) {
return isThis(world.getBlockState(pos));
}
private boolean isThis(BlockState state) {
return state.getBlock() instanceof StalactiteBlock;
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
return Blocks.AIR.defaultBlockState();
}
return state;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
int size = state.get(SIZE);
int size = state.getValue(SIZE);
return checkUp(world, pos, size) || checkDown(world, pos, size);
}
private boolean checkUp(BlockView world, BlockPos pos, int size) {
BlockPos p = pos.up();
BlockState state = world.getBlockState(p);
return (isThis(state) && state.get(SIZE) >= size) || state.isFullCube(world, p);
return (isThis(state) && state.getValue(SIZE) >= size) || state.isFullCube(world, p);
}
private boolean checkDown(BlockView world, BlockPos pos, int size) {
BlockPos p = pos.down();
BlockPos p = pos.below();
BlockState state = world.getBlockState(p);
return (isThis(state) && state.get(SIZE) >= size) || state.isFullCube(world, p);
return (isThis(state) && state.getValue(SIZE) >= size) || state.isFullCube(world, p);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_CROSS_SHADED, block);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_STALACTITE;
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
}
@Override
@ -230,7 +221,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements Waterloggable,
float start = 5F / 8F;
SHAPES = new VoxelShape[8];
for (int i = 0; i < 8; i++) {
int side = MathHelper.floor(MathHelper.lerp(i / 7F, start, end) * 8F + 0.5F);
int side = Mth.floor(Mth.lerp(i / 7F, start, end) * 8F + 0.5F);
SHAPES[i] = Block.createCuboidShape(side, 0, side, 16 - side, 16, 16 - side);
}
}

View file

@ -3,18 +3,18 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.registry.Registry;
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.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.core.Vec3i;
import net.minecraft.core.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.level.BlockGetter;
import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.patterns.Patterns;
@ -24,13 +24,13 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(3, 1, 3, 13, 16, 13);
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(3, 0, 3, 13, 15, 13);
private static final Vec3i[] COLORS = AuroraCrystalBlock.COLORS;
public StoneLanternBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(15));
}
@Override
public BlockColorProvider getProvider() {
public BlockColor getBlockProvider() {
return (state, world, pos, tintIndex) -> {
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1;
@ -38,47 +38,47 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return MHelper.color(r, g, b);
};
}
@Override
public ItemColorProvider getItemProvider() {
public ItemColor getItemProvider() {
return (stack, tintIndex) -> {
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
};
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_STONE_LANTERN;
}
@Override
public String getModelPattern(String block) {
String texture = Registry.BLOCK.getId(this).getPath();
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
}
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, texture, texture);
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getId(this).getPath();
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
}

View file

@ -2,36 +2,38 @@ package ru.betterend.blocks.basis;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.PillarBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class StrippableBarkBlock extends BarkBlock {
private final Block striped;
public StrippableBarkBlock(MaterialColor color, Block striped) {
super(FabricBlockSettings.copyOf(striped).materialColor(color));
this.striped = striped;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (player.getMainHandStack().getItem().isIn(FabricToolTags.AXES)) {
world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isClient) {
world.setBlockState(pos, striped.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11);
world.playLocalSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlockAndUpdate(pos, striped.defaultBlockState().with(RotatedPillarBlock.AXIS,
state.getValue(RotatedPillarBlock.AXIS)), 11);
if (player != null && !player.isCreative()) {
player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player);
player.getMainHandStack().damage(1, world.random, (ServerPlayer) player);
}
}
return ActionResult.SUCCESS;

View file

@ -5,23 +5,23 @@ import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
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.entity.player.PlayerEntity;
import net.minecraft.world.item.ItemPlacementContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
@ -30,27 +30,28 @@ import ru.betterend.patterns.Patterns;
public class TripleTerrainBlock extends EndTerrainBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public TripleTerrainBlock(MaterialColor color) {
super(color);
this.setDefaultState(this.getDefaultState().with(SHAPE, TripleShape.BOTTOM));
this.setDefaultState(this.defaultBlockState().with(SHAPE, TripleShape.BOTTOM));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction dir = ctx.getSide();
TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM : dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE;
return this.getDefaultState().with(SHAPE, shape);
TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM
: dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE;
return this.defaultBlockState().with(SHAPE, shape);
}
@Override
public String getModelPattern(String block) {
String name = Registry.BLOCK.getId(this).getPath();
String name = Registry.BLOCK.getKey(this).getPath();
if (block.endsWith("_middle")) {
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
}
@ -60,65 +61,60 @@ public class TripleTerrainBlock extends EndTerrainBlock {
map.put("%bottom%", "minecraft:block/end_stone");
return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map);
}
@Override
public Identifier statePatternId() {
public ResourceLocation statePatternId() {
return Patterns.STATE_TRIPLE_ROTATED_TOP;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
TripleShape shape = state.get(SHAPE);
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) {
return super.onUse(state, world, pos, player, hand, hit);
}
return ActionResult.FAIL;
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
TripleShape shape = state.get(SHAPE);
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
TripleShape shape = state.getValue(SHAPE);
if (shape == TripleShape.BOTTOM) {
super.randomTick(state, world, pos, random);
return;
}
else if (random.nextInt(16) == 0) {
} else if (random.nextInt(16) == 0) {
boolean bottom = canSurviveBottom(world, pos);
if (shape == TripleShape.TOP) {
if (!bottom) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
}
}
else {
} else {
boolean top = canSurvive(state, world, pos) || isMiddle(world.getBlockState(pos.up()));
if (!top && !bottom) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
}
else if (top && !bottom) {
world.setBlockState(pos, state.with(SHAPE, TripleShape.BOTTOM));
}
else if (!top && bottom) {
world.setBlockState(pos, state.with(SHAPE, TripleShape.TOP));
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
} else if (top && !bottom) {
world.setBlockAndUpdate(pos, state.with(SHAPE, TripleShape.BOTTOM));
} else if (!top && bottom) {
world.setBlockAndUpdate(pos, state.with(SHAPE, TripleShape.TOP));
}
}
}
}
protected boolean canSurviveBottom(WorldView world, BlockPos pos) {
BlockPos blockPos = pos.down();
BlockPos blockPos = pos.below();
BlockState blockState = world.getBlockState(blockPos);
if (isMiddle(blockState)) {
return true;
}
else if (blockState.getFluidState().getLevel() == 8) {
} else if (blockState.getFluidState().getLevel() == 8) {
return false;
}
else {
} else {
return !blockState.isSideSolidFullSquare(world, blockPos, Direction.UP);
}
}
protected boolean isMiddle(BlockState state) {
return state.isOf(this) && state.get(SHAPE) == TripleShape.MIDDLE;
return state.is(this) && state.getValue(SHAPE) == TripleShape.MIDDLE;
}
}

View file

@ -7,32 +7,32 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.ItemEntity;
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.block.Fertilizable;
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.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.entity.ItemEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -41,25 +41,18 @@ import ru.betterend.registry.EndTags;
public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable, FluidFillable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
public UnderwaterPlantBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).breakByHand(true).noCollision());
}
public UnderwaterPlantBlock(int light) {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.luminance(light)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).luminance(light).breakByHand(true).noCollision());
}
public UnderwaterPlantBlock(Settings settings) {
public UnderwaterPlantBlock(Properties settings) {
super(settings);
}
@ -76,37 +69,37 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
state = world.getBlockState(pos);
return isTerrain(down) && state.getFluidState().getFluid().equals(Fluids.WATER.getStill());
}
protected boolean isTerrain(BlockState state) {
return state.isIn(EndTags.END_GROUND) || state.getBlock() == EndBlocks.ENDSTONE_DUST;
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
world.breakBlock(pos, true);
return Blocks.WATER.getDefaultState();
}
else {
return Blocks.WATER.defaultBlockState();
} else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
@ -118,13 +111,14 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
return true;
}
@Override
public void grow(ServerWorld 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(this));
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(this));
world.spawnEntity(item);
}
@ -134,10 +128,10 @@ public class UnderwaterPlantBlock extends BlockBaseNotFull implements IRenderTyp
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getStill(false);

View file

@ -4,51 +4,46 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
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.server.level.ServerLevel;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties;
public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
public static final IntProperty AGE = BlockProperties.AGE;
public static final IntegerProperty AGE = BlockProperties.AGE;
public UnderwaterPlantWithAgeBlock() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
.sounds(SoundType.WET_GRASS).breakByHand(true).ticksRandomly().noCollision());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
}
public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos);
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
if (random.nextInt(4) == 0) {
int age = state.get(AGE);
int age = state.getValue(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
}
else {
world.setBlockAndUpdate(pos, state.with(AGE, age + 1));
} else {
grow(world, random, pos);
}
}
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);

View file

@ -6,25 +6,25 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.level.block.entity.BlockEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.entity.player.PlayerEntity;
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 net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -32,13 +32,10 @@ import ru.betterend.registry.EndTags;
public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
public UpDownPlantBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.breakByHand(true).noCollision());
}
@Override
@ -48,48 +45,49 @@ public class UpDownPlantBlock extends BlockBaseNotFull implements IRenderTypeabl
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
BlockState down = world.getBlockState(pos.below());
BlockState up = world.getBlockState(pos.up());
return (isTerrain(down) || down.getBlock() == this) && (isSupport(up, world, pos) || up.getBlock() == this);
}
protected boolean isTerrain(BlockState state) {
return state.isIn(EndTags.END_GROUND);
}
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {
return sideCoversSmallSquare(world, pos.up(), Direction.UP);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return Blocks.AIR.defaultBlockState();
} else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) {
public void afterBreak(Level world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity,
ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
world.updateNeighbor(pos, Blocks.AIR, pos.down());
world.updateNeighbor(pos, Blocks.AIR, pos.below());
}
}

View file

@ -7,30 +7,30 @@ 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.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
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.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.world.level.block.state.StateDefinition;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.tags.BlockTags;
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.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
@ -41,29 +41,25 @@ import ru.betterend.util.BlocksHelper;
public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VOXEL_SHAPE = Block.createCuboidShape(2, 0, 2, 14, 16, 14);
public VineBlock() {
this(0, false);
}
public VineBlock(int light) {
this(light, false);
}
public VineBlock(int light, boolean bottomOnly) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS)
.luminance((state) -> {
return bottomOnly ? state.get(SHAPE) == TripleShape.BOTTOM ? light : 0 : light;
})
.breakByHand(true)
.noCollision());
this.setDefaultState(this.stateManager.getDefaultState().with(SHAPE, TripleShape.BOTTOM));
return bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light;
}).breakByHand(true).noCollision());
this.setDefaultState(this.stateManager.defaultBlockState().with(SHAPE, TripleShape.BOTTOM));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@ -77,7 +73,7 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.XZ;
}
public boolean canGenerate(BlockState state, WorldView world, BlockPos pos) {
return isSupport(state, world, pos);
}
@ -86,37 +82,37 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return isSupport(state, world, pos);
}
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {
BlockState up = world.getBlockState(pos.up());
return up.isOf(this) || up.isIn(BlockTags.LEAVES) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
return up.is(this) || up.isIn(BlockTags.LEAVES) || sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
if (world.getBlockState(pos.down()).getBlock() != this)
return Blocks.AIR.defaultBlockState();
} else {
if (world.getBlockState(pos.below()).getBlock() != this)
return state.with(SHAPE, TripleShape.BOTTOM);
else if (world.getBlockState(pos.up()).getBlock() != this)
return state.with(SHAPE, TripleShape.TOP);
return state.with(SHAPE, TripleShape.MIDDLE);
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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) {
return Lists.newArrayList(new ItemStack(this));
}
else {
} else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
@ -125,25 +121,25 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
while (world.getBlockState(pos).getBlock() == this) {
pos = pos.down();
pos = pos.below();
}
return world.getBlockState(pos).isAir();
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) {
pos = pos.down();
pos = pos.below();
}
return world.isAir(pos);
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) {
pos = pos.down();
pos = pos.below();
}
world.setBlockState(pos, getDefaultState());
world.setBlockAndUpdate(pos, getDefaultState());
BlocksHelper.setWithoutUpdate(world, pos, getDefaultState());
}
}

View file

@ -6,32 +6,26 @@ 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.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.WorldView;
public class WallMushroomBlock extends EndWallPlantBlock {
public WallMushroomBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.AXES)
.sounds(BlockSoundGroup.GRASS)
.luminance(light)
.sounds(BlockSoundGroup.WOOD)
.hardness(0.2F)
.breakByHand(true)
.noCollision());
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.AXES).sounds(SoundType.GRASS)
.luminance(light).sounds(SoundType.WOOD).hardness(0.2F).breakByHand(true).noCollision());
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));
}
@Override
public boolean isSupport(WorldView world, BlockPos pos, BlockState blockState, Direction direction) {
return blockState.getMaterial().isSolid() && blockState.isSideSolidFullSquare(world, pos, direction);