From e4f0ecd7a92127aa39b8cf5ad786f2e8033de668 Mon Sep 17 00:00:00 2001 From: Lizbeth Rika Date: Thu, 19 Feb 2015 23:13:07 +0000 Subject: [PATCH] Fixed the force relay being able to destroy blocks in the world (bedrock included). Also fixed a rare crash that happened randomly it seems. --- .../vazkii/botania/common/block/BlockPistonRelay.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java index 8b3a00a60..dd98268ab 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java @@ -19,6 +19,7 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -211,7 +212,12 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl String[] tokens = s.split(":"); int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]); World world = server.worldServerForDimension(worldId); - world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); + if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) + world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay); + else if(!world.isRemote) { + ItemStack stack = new ItemStack(ModBlocks.pistonRelay); + world.spawnEntityInWorld(new EntityItem(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, stack)); + } checkedCoords.add(s); newPos = getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); } @@ -251,7 +257,8 @@ public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconabl ArrayList remove = new ArrayList(removeThese); for(String s : remove) { coordsToCheck.remove(s); - checkedCoords.remove(s); + if(checkedCoords.contains(s)) + checkedCoords.remove(s); } removeThese.clear(); }