mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-10-26 14:33:48 +00:00
Use correct place/break event pattern in dislocation focus
This commit is contained in:
1 parent
3beb0d9d56
commit
9fee0314b3
1 file changed
+10
-19
@@ -104,13 +104,6 @@ public class ItemFocusDislocation extends ItemModFocus {
|
||||
player));
|
||||
}
|
||||
|
||||
private static boolean canPlaceBlock(World world, EntityPlayer player, int x, int y, int z, int side) {
|
||||
return !ForgeEventFactory.onPlayerBlockPlace(
|
||||
player,
|
||||
BlockSnapshot.getBlockSnapshot(world, x, y, z),
|
||||
ForgeDirection.getOrientation(side)).isCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player,
|
||||
MovingObjectPosition mop) {
|
||||
@@ -132,19 +125,17 @@ public class ItemFocusDislocation extends ItemModFocus {
|
||||
if (mop.sideHit == 5) ++mop.blockX;
|
||||
|
||||
if (block.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
|
||||
if (!world.isRemote
|
||||
&& !canPlaceBlock(world, player, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit))
|
||||
Block toPlace = ((ItemBlock) stack.getItem()).field_150939_a;
|
||||
BlockSnapshot snapshot = BlockSnapshot.getBlockSnapshot(world, mop.blockX, mop.blockY, mop.blockZ);
|
||||
world.setBlock(mop.blockX, mop.blockY, mop.blockZ, toPlace, stack.getItemDamage(), 1 | 2);
|
||||
if (ForgeEventFactory
|
||||
.onPlayerBlockPlace(player, snapshot, ForgeDirection.getOrientation(mop.sideHit))
|
||||
.isCanceled()) {
|
||||
snapshot.restore(true, false);
|
||||
return itemstack;
|
||||
}
|
||||
toPlace.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, stack);
|
||||
if (!world.isRemote) {
|
||||
world.setBlock(
|
||||
mop.blockX,
|
||||
mop.blockY,
|
||||
mop.blockZ,
|
||||
((ItemBlock) stack.getItem()).field_150939_a,
|
||||
stack.getItemDamage(),
|
||||
1 | 2);
|
||||
((ItemBlock) stack.getItem()).field_150939_a
|
||||
.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, stack);
|
||||
NBTTagCompound tileCmp = getStackTileEntity(itemstack);
|
||||
if (tileCmp != null && !tileCmp.hasNoTags()) {
|
||||
TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
|
||||
@@ -170,7 +161,7 @@ public class ItemFocusDislocation extends ItemModFocus {
|
||||
&& !ThaumcraftApi.portableHoleBlackList.contains(block)
|
||||
&& block != null
|
||||
&& block.getBlockHardness(world, mop.blockX, mop.blockY, mop.blockZ) != -1F
|
||||
&& (world.isRemote || canBreakBlock(world, player, mop.blockX, mop.blockY, mop.blockZ))
|
||||
&& canBreakBlock(world, player, mop.blockX, mop.blockY, mop.blockZ)
|
||||
&& wand.consumeAllVis(itemstack, player, getCost(tile), true, false)) {
|
||||
if (!world.isRemote) {
|
||||
world.removeTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
Reference in new issue
Block a user