fixes drill harvesting bug - drills can be mined again

This commit is contained in:
Jottyfan 2024-12-15 15:01:18 +01:00
parent c2558a5324
commit 81e45c56ce
2 changed files with 16 additions and 3 deletions

View File

@ -9,7 +9,7 @@ yarn_mappings=1.21.4+build.1
loader_version=0.16.9
# Mod Properties
mod_version=1.21.4.3
mod_version=1.21.4.4
maven_group=de.jottyfan.quickiemod
archives_base_name=quickiemod

View File

@ -41,10 +41,11 @@ import net.minecraft.world.World;
public class BlockDrill extends FallingBlock implements BlockEntityProvider {
private static final Integer MAX_FUEL = 255;
public static final IntProperty FUEL = IntProperty.of("fuel", 0, MAX_FUEL);
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("direction", Direction.class, Direction.values());
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("direction", Direction.class,
Direction.values());
public BlockDrill(Identifier identifier, Direction direction) {
super(AbstractBlock.Settings.create().hardness(2.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
super(AbstractBlock.Settings.create().hardness(0.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
setDefaultState(getDefaultState().with(FUEL, 0).with(DIRECTION, direction));
}
@ -68,8 +69,20 @@ public class BlockDrill extends FallingBlock implements BlockEntityProvider {
@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
Integer fuelLeft = state.get(FUEL);
Direction dir = state.get(DIRECTION);
world.spawnEntity(
new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.ITEM_CANOLABOTTLE, fuelLeft)));
Block thisBlock = ModBlocks.BLOCK_DRILL_DOWN;
if (Direction.EAST.equals(dir)) {
thisBlock = ModBlocks.BLOCK_DRILL_EAST;
} else if (Direction.SOUTH.equals(dir)) {
thisBlock = ModBlocks.BLOCK_DRILL_SOUTH;
} else if (Direction.WEST.equals(dir)) {
thisBlock = ModBlocks.BLOCK_DRILL_WEST;
} else if (Direction.NORTH.equals(dir)) {
thisBlock = ModBlocks.BLOCK_DRILL_NORTH;
}
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(thisBlock)));
return super.onBreak(world, pos, state, player);
}