repaired drills
This commit is contained in:
parent
039acc3c64
commit
51c4c6a00d
@ -1,8 +1,6 @@
|
||||
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;
|
||||
@ -12,56 +10,18 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -10,29 +10,18 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -10,29 +10,18 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -10,29 +10,17 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -10,30 +10,18 @@ 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user