repaired drills
This commit is contained in:
		| @@ -1,8 +1,6 @@ | |||||||
| package de.jottyfan.minecraft.quickiefabric.blockentity; | package de.jottyfan.minecraft.quickiefabric.blockentity; | ||||||
|  |  | ||||||
| import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks; |  | ||||||
| import net.minecraft.block.BlockState; | import net.minecraft.block.BlockState; | ||||||
| import net.minecraft.block.Blocks; |  | ||||||
| import net.minecraft.block.entity.BlockEntity; | import net.minecraft.block.entity.BlockEntity; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
| @@ -12,56 +10,18 @@ import net.minecraft.world.World; | |||||||
|  * @author jotty |  * @author jotty | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class DrillBlockDownEntity extends BlockEntity { | public class DrillBlockDownEntity extends DrillBlockEntity { | ||||||
|  |  | ||||||
| 	private static final Integer MAXDRILLSTEP = 20; | 	private static final Integer MAXDRILLSTEP = 20; | ||||||
| 	private Integer drillstep; |  | ||||||
|  |  | ||||||
| 	public DrillBlockDownEntity(BlockPos pos, BlockState state) { | 	public DrillBlockDownEntity(BlockPos pos, BlockState state) { | ||||||
| 		super(QuickieFabricBlockEntity.DRILL_DOWN, pos, state); | 		super(QuickieFabricBlockEntity.DRILL_DOWN, pos, state, MAXDRILLSTEP); | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	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); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | ||||||
| 		if (be instanceof DrillBlockDownEntity) { | 		if (be instanceof DrillBlockDownEntity) { | ||||||
| 			DrillBlockDownEntity dbde = (DrillBlockDownEntity) be; | 			DrillBlockDownEntity dbe = (DrillBlockDownEntity) be; | ||||||
| 			if (dbde.getDrillstep() < 1) { | 			DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.down()); | ||||||
| 				dbde.setDrillstep(MAXDRILLSTEP); |  | ||||||
| 				drill(pos, pos.down(), world); |  | ||||||
| 			} else { |  | ||||||
| 				dbde.doDrillstep(); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	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 |  * @author jotty | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class DrillBlockEastEntity extends BlockEntity { | public class DrillBlockEastEntity extends DrillBlockEntity { | ||||||
|  |  | ||||||
| 	private static final Integer MAXDRILLSTEP = 24; | 	private static final Integer MAXDRILLSTEP = 24; | ||||||
| 	private Integer drillstep; |  | ||||||
|  |  | ||||||
| 	public DrillBlockEastEntity(BlockPos pos, BlockState state) { | 	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) { | 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | ||||||
| 		if (be instanceof DrillBlockEastEntity) { | 		if (be instanceof DrillBlockEastEntity) { | ||||||
| 			DrillBlockEastEntity dbwe = (DrillBlockEastEntity) be; | 			DrillBlockEastEntity dbe = (DrillBlockEastEntity) be; | ||||||
| 			if (dbwe.getDrillstep() < 1) { | 			DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.east().down()); | ||||||
| 				dbwe.setDrillstep(MAXDRILLSTEP); |  | ||||||
| 				DrillBlockDownEntity.drill(pos, pos.east().down(), world); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	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 |  * @author jotty | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class DrillBlockNorthEntity extends BlockEntity { | public class DrillBlockNorthEntity extends DrillBlockEntity { | ||||||
|  |  | ||||||
| 	private static final Integer MAXDRILLSTEP = 24; | 	private static final Integer MAXDRILLSTEP = 24; | ||||||
| 	private Integer drillstep; |  | ||||||
|  |  | ||||||
| 	public DrillBlockNorthEntity(BlockPos pos, BlockState state) { | 	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) { | 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | ||||||
| 		if (be instanceof DrillBlockNorthEntity) { | 		if (be instanceof DrillBlockNorthEntity) { | ||||||
| 			DrillBlockNorthEntity dbwe = (DrillBlockNorthEntity) be; | 			DrillBlockNorthEntity dbe = (DrillBlockNorthEntity) be; | ||||||
| 			if (dbwe.getDrillstep() < 1) { | 			DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.north().down()); | ||||||
| 				dbwe.setDrillstep(MAXDRILLSTEP); |  | ||||||
| 				DrillBlockDownEntity.drill(pos, pos.north().down(), world); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	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 |  * @author jotty | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class DrillBlockSouthEntity extends BlockEntity { | public class DrillBlockSouthEntity extends DrillBlockEntity { | ||||||
| 	private static final Integer MAXDRILLSTEP = 24; | 	private static final Integer MAXDRILLSTEP = 24; | ||||||
| 	private Integer drillstep; |  | ||||||
|  |  | ||||||
| 	public DrillBlockSouthEntity(BlockPos pos, BlockState state) { | 	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) { | 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | ||||||
| 		if (be instanceof DrillBlockSouthEntity) { | 		if (be instanceof DrillBlockSouthEntity) { | ||||||
| 			DrillBlockSouthEntity dbwe = (DrillBlockSouthEntity) be; | 			DrillBlockSouthEntity dbe = (DrillBlockSouthEntity) be; | ||||||
| 			if (dbwe.getDrillstep() < 1) { | 			DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.south().down()); | ||||||
| 				dbwe.setDrillstep(MAXDRILLSTEP); |  | ||||||
| 				DrillBlockDownEntity.drill(pos, pos.south().down(), world); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	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 |  * @author jotty | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| public class DrillBlockWestEntity extends BlockEntity { | public class DrillBlockWestEntity extends DrillBlockEntity { | ||||||
|  |  | ||||||
| 	private static final Integer MAXDRILLSTEP = 24; | 	private static final Integer MAXDRILLSTEP = 24; | ||||||
| 	private Integer drillstep; |  | ||||||
|  |  | ||||||
| 	public DrillBlockWestEntity(BlockPos pos, BlockState state) { | 	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) { | 	public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) { | ||||||
| 		if (be instanceof DrillBlockWestEntity) { | 		if (be instanceof DrillBlockWestEntity) { | ||||||
| 			DrillBlockWestEntity dbwe = (DrillBlockWestEntity) be; | 			DrillBlockWestEntity dbe = (DrillBlockWestEntity) be; | ||||||
| 			if (dbwe.getDrillstep() < 1) { | 			DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, pos.west().down()); | ||||||
| 				dbwe.setDrillstep(MAXDRILLSTEP); |  | ||||||
| 				DrillBlockDownEntity.drill(pos, pos.west().down(), world); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Integer getDrillstep() { |  | ||||||
| 		return drillstep == null ? MAXDRILLSTEP : drillstep; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	public void setDrillstep(Integer drillstep) { |  | ||||||
| 		this.drillstep = drillstep; |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user