Compare commits

...
11 Commits
Author SHA1 Message Date
Algent d69e3b8d4d Merge branch 'master' into algent/focus-SU 2026-09-05 10:39:29 +02:00
Algent 677319bd44 Merge remote-tracking branch 'origin/algent/focus-SU' 2026-09-05 10:37:56 +02:00
Algent 82981b771a fix(dislocation): guard stored block placement
Honor destination placement events and restore canceled placements.
Retain the stored block on failure and validate its placement rules
without allowing occupied destinations to be overwritten.
2026-09-05 10:33:46 +02:00
Algent d49826acdf Merge branch 'master' into algent/focus-SU 2026-08-30 11:42:55 +02:00
Algent 59b606205a fix(dislocation): guard block extraction
Check vis before posting BreakEvent, then let server-side claim protection cancel pickup before vis consumption or world mutation. Revert unrelated placement-event handling.
2026-08-30 11:41:05 +02:00
Algent 0a79682d32 Merge branch 'master' into algent/focus-SU 2026-08-26 20:57:14 +03:00
Algent 9bc9ee5e81 Merge branch 'master' into algent/focus-SU 2026-08-04 12:21:42 +02:00
Algent 93710edf2c Apply review suggestion 2026-08-04 12:21:25 +02:00
Algent 9fee0314b3 Use correct place/break event pattern in dislocation focus 2026-07-24 13:30:38 +02:00
Algent 3beb0d9d56 Merge branch 'master' into algent/focus-SU 2026-07-17 00:16:47 +02:00
Algent 666bc97928 Fix dislocation focus not respecting forge events 2026-06-28 23:53:26 +02:00
@@ -26,6 +26,11 @@ import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.world.BlockEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -87,6 +92,18 @@ public class ItemFocusDislocation extends ItemModFocus {
return true;
}
private static boolean canBreakBlock(World world, EntityPlayer player, int x, int y, int z) {
return !MinecraftForge.EVENT_BUS.post(
new BlockEvent.BreakEvent(
x,
y,
z,
world,
world.getBlock(x, y, z),
world.getBlockMetadata(x, y, z),
player));
}
@Override
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player,
MovingObjectPosition mop) {
@@ -107,17 +124,30 @@ public class ItemFocusDislocation extends ItemModFocus {
if (mop.sideHit == 4) --mop.blockX;
if (mop.sideHit == 5) ++mop.blockX;
if (block.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
Block toPlace = ((ItemBlock) stack.getItem()).field_150939_a;
if (mop.blockY >= 0 && mop.blockY < world.getHeight()
&& player.canPlayerEdit(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, itemstack)
&& world.getBlock(mop.blockX, mop.blockY, mop.blockZ)
.isReplaceable(world, mop.blockX, mop.blockY, mop.blockZ)
&& toPlace.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
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);
BlockSnapshot snapshot = BlockSnapshot
.getBlockSnapshot(world, mop.blockX, mop.blockY, mop.blockZ);
if (!world.setBlock(mop.blockX, mop.blockY, mop.blockZ, toPlace, stack.getItemDamage(), 2))
return itemstack;
if (ForgeEventFactory
.onPlayerBlockPlace(player, snapshot, ForgeDirection.getOrientation(mop.sideHit))
.isCanceled()) {
boolean restoring = world.restoringBlockSnapshots;
world.restoringBlockSnapshots = true;
try {
snapshot.restore(true, false);
} finally {
world.restoringBlockSnapshots = restoring;
}
return itemstack;
}
toPlace.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, stack);
NBTTagCompound tileCmp = getStackTileEntity(itemstack);
if (tileCmp != null && !tileCmp.hasNoTags()) {
TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
@@ -126,6 +156,8 @@ public class ItemFocusDislocation extends ItemModFocus {
tile1.zCoord = mop.blockZ;
world.setTileEntity(mop.blockX, mop.blockY, mop.blockZ, tile1);
}
clearPickedBlock(itemstack);
world.notifyBlockChange(mop.blockX, mop.blockY, mop.blockZ, toPlace);
} else {
player.swingItem();
for (int i = 0; i < 8; i++) {
@@ -135,14 +167,14 @@ public class ItemFocusDislocation extends ItemModFocus {
ThaumicTinkerer.tcProxy.burst(world, x, y, z, 0.2F);
}
}
clearPickedBlock(itemstack);
world.playSoundAtEntity(player, "thaumcraft:wand", 0.5F, 1F);
}
} else if (!blacklist.contains(block) && isBlockAllowed(block)
&& !ThaumcraftApi.portableHoleBlackList.contains(block)
&& block != null
&& block.getBlockHardness(world, mop.blockX, mop.blockY, mop.blockZ) != -1F
&& wand.consumeAllVis(itemstack, player, getCost(tile), false, false)
&& (world.isRemote || 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);