diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockDownEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockDownEntity.java index 5ea5b1b..cb2adb1 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockDownEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockDownEntity.java @@ -1,67 +1,27 @@ package de.jottyfan.minecraft.quickiefabric.blockentity; -import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** - * + * * @author jotty * */ -public class DrillBlockDownEntity extends BlockEntity { +public class DrillBlockDownEntity extends DrillBlockEntity { private static final Integer MAXDRILLSTEP = 20; - private Integer drillstep; public DrillBlockDownEntity(BlockPos pos, BlockState state) { - super(QuickieFabricBlockEntity.DRILL_DOWN, pos, state); - } - - protected static final void moveBlockWithEntity(BlockPos from, BlockPos to, World world) { - BlockEntity be = world.getBlockEntity(from); - BlockState bs = world.getBlockState(from); - if (be != null) { - world.setBlockState(from, Blocks.AIR.getDefaultState()); - world.setBlockState(to, bs); - world.removeBlockEntity(from); - world.addBlockEntity(be); - } - } - - protected static final void drill(BlockPos pos, BlockPos to, World world) { - if (!world.getBlockState(to).isOf(Blocks.BEDROCK) && !world.getBlockState(to).isOf(QuickieBlocks.DRILLSTOP)) { - world.breakBlock(to, true); - if (pos.down() != to) { // no need for the falling one - moveBlockWithEntity(pos, to, world); - } - } + super(QuickieFabricBlockEntity.DRILL_DOWN, pos, state, MAXDRILLSTEP); } public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { if (be instanceof DrillBlockDownEntity) { - DrillBlockDownEntity dbde = (DrillBlockDownEntity) be; - if (dbde.getDrillstep() < 1) { - dbde.setDrillstep(MAXDRILLSTEP); - drill(pos, pos.down(), world); - } else { - dbde.doDrillstep(); - } + DrillBlockDownEntity dbe = (DrillBlockDownEntity) be; + DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.down()); } } - - public void doDrillstep() { - setDrillstep(getDrillstep() - 1); - } - - public Integer getDrillstep() { - return drillstep == null ? MAXDRILLSTEP : drillstep; - } - - public void setDrillstep(Integer drillstep) { - this.drillstep = drillstep; - } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockEastEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockEastEntity.java index 14a8e28..698de15 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockEastEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockEastEntity.java @@ -6,33 +6,22 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** - * + * * @author jotty * */ -public class DrillBlockEastEntity extends BlockEntity { +public class DrillBlockEastEntity extends DrillBlockEntity { + private static final Integer MAXDRILLSTEP = 24; - private Integer drillstep; public DrillBlockEastEntity(BlockPos pos, BlockState state) { - super(QuickieFabricBlockEntity.DRILL_EAST, pos, state); + super(QuickieFabricBlockEntity.DRILL_EAST, pos, state, MAXDRILLSTEP); } public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { if (be instanceof DrillBlockEastEntity) { - DrillBlockEastEntity dbwe = (DrillBlockEastEntity) be; - if (dbwe.getDrillstep() < 1) { - dbwe.setDrillstep(MAXDRILLSTEP); - DrillBlockDownEntity.drill(pos, pos.east().down(), world); - } + DrillBlockEastEntity dbe = (DrillBlockEastEntity) be; + DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.east().down()); } } - - public Integer getDrillstep() { - return drillstep == null ? MAXDRILLSTEP : drillstep; - } - - public void setDrillstep(Integer drillstep) { - this.drillstep = drillstep; - } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockNorthEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockNorthEntity.java index 52b68ce..42585d9 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockNorthEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockNorthEntity.java @@ -6,33 +6,22 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** - * + * * @author jotty * */ -public class DrillBlockNorthEntity extends BlockEntity { +public class DrillBlockNorthEntity extends DrillBlockEntity { + private static final Integer MAXDRILLSTEP = 24; - private Integer drillstep; public DrillBlockNorthEntity(BlockPos pos, BlockState state) { - super(QuickieFabricBlockEntity.DRILL_NORTH, pos, state); + super(QuickieFabricBlockEntity.DRILL_NORTH, pos, state, MAXDRILLSTEP); } public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { if (be instanceof DrillBlockNorthEntity) { - DrillBlockNorthEntity dbwe = (DrillBlockNorthEntity) be; - if (dbwe.getDrillstep() < 1) { - dbwe.setDrillstep(MAXDRILLSTEP); - DrillBlockDownEntity.drill(pos, pos.north().down(), world); - } + DrillBlockNorthEntity dbe = (DrillBlockNorthEntity) be; + DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.north().down()); } } - - public Integer getDrillstep() { - return drillstep == null ? MAXDRILLSTEP : drillstep; - } - - public void setDrillstep(Integer drillstep) { - this.drillstep = drillstep; - } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockSouthEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockSouthEntity.java index 57c1ac3..2126553 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockSouthEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockSouthEntity.java @@ -6,33 +6,21 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** - * + * * @author jotty * */ -public class DrillBlockSouthEntity extends BlockEntity { +public class DrillBlockSouthEntity extends DrillBlockEntity { private static final Integer MAXDRILLSTEP = 24; - private Integer drillstep; public DrillBlockSouthEntity(BlockPos pos, BlockState state) { - super(QuickieFabricBlockEntity.DRILL_SOUTH, pos, state); + super(QuickieFabricBlockEntity.DRILL_SOUTH, pos, state, MAXDRILLSTEP); } public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { if (be instanceof DrillBlockSouthEntity) { - DrillBlockSouthEntity dbwe = (DrillBlockSouthEntity) be; - if (dbwe.getDrillstep() < 1) { - dbwe.setDrillstep(MAXDRILLSTEP); - DrillBlockDownEntity.drill(pos, pos.south().down(), world); - } + DrillBlockSouthEntity dbe = (DrillBlockSouthEntity) be; + DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.south().down()); } } - - public Integer getDrillstep() { - return drillstep == null ? MAXDRILLSTEP : drillstep; - } - - public void setDrillstep(Integer drillstep) { - this.drillstep = drillstep; - } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockWestEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockWestEntity.java index 9593f3a..2238b7f 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockWestEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/DrillBlockWestEntity.java @@ -6,34 +6,22 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** - * + * * @author jotty * */ -public class DrillBlockWestEntity extends BlockEntity { +public class DrillBlockWestEntity extends DrillBlockEntity { private static final Integer MAXDRILLSTEP = 24; - private Integer drillstep; public DrillBlockWestEntity(BlockPos pos, BlockState state) { - super(QuickieFabricBlockEntity.DRILL_WEST, pos, state); + super(QuickieFabricBlockEntity.DRILL_WEST, pos, state, MAXDRILLSTEP); } public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { if (be instanceof DrillBlockWestEntity) { - DrillBlockWestEntity dbwe = (DrillBlockWestEntity) be; - if (dbwe.getDrillstep() < 1) { - dbwe.setDrillstep(MAXDRILLSTEP); - DrillBlockDownEntity.drill(pos, pos.west().down(), world); - } + DrillBlockWestEntity dbe = (DrillBlockWestEntity) be; + DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.west().down()); } } - - public Integer getDrillstep() { - return drillstep == null ? MAXDRILLSTEP : drillstep; - } - - public void setDrillstep(Integer drillstep) { - this.drillstep = drillstep; - } }