diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index f0b1703ddf..7bf7269945 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -97,7 +97,7 @@ public class CraftBanner extends CraftBlockState implements Banner { @Override public boolean update(boolean force, boolean applyPhysics) { - boolean result = (isPlaced()) ? super.update(force, applyPhysics) : true; + boolean result = super.update(force, applyPhysics); if (result) { banner.color = EnumColor.fromInvColorIndex(base.getDyeData()); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 09fddf4ac4..5d83155a12 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -151,7 +151,9 @@ public class CraftBlockState implements BlockState { } public boolean update(boolean force, boolean applyPhysics) { - requirePlaced(); + if (!isPlaced()) { + return true; + } Block block = getBlock(); if (block.getType() != getType()) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java index a6253bcee6..9bbc790509 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java @@ -44,7 +44,7 @@ public class CraftCommandBlock extends CraftBlockState implements CommandBlock { } public boolean update(boolean force, boolean applyPhysics) { - boolean result = (isPlaced()) ? super.update(force, applyPhysics) : true; + boolean result = super.update(force, applyPhysics); if (result) { commandBlock.getCommandBlock().setCommand(command); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java b/src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java index 7b909e34e4..c3c3bd08e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java @@ -4,10 +4,9 @@ import net.minecraft.server.TileEntity; import net.minecraft.server.TileEntityComparator; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.EnderChest; import org.bukkit.craftbukkit.CraftWorld; -public class CraftComparator extends CraftBlockState implements EnderChest { +public class CraftComparator extends CraftBlockState { private final CraftWorld world; private final TileEntityComparator comparator; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDaylightDetector.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDaylightDetector.java index f43a9a36c0..b970727cfb 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftDaylightDetector.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDaylightDetector.java @@ -4,10 +4,9 @@ import net.minecraft.server.TileEntity; import net.minecraft.server.TileEntityLightDetector; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.EnderChest; import org.bukkit.craftbukkit.CraftWorld; -public class CraftDaylightDetector extends CraftBlockState implements EnderChest { +public class CraftDaylightDetector extends CraftBlockState { private final CraftWorld world; private final TileEntityLightDetector detector; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java index a22fed36af..e6a5bc1ad0 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java @@ -8,23 +8,25 @@ import org.bukkit.block.Block; import org.bukkit.block.FlowerPot; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.material.MaterialData; public class CraftFlowerPot extends CraftBlockState implements FlowerPot { private final TileEntityFlowerPot pot; + private MaterialData contents; public CraftFlowerPot(Block block) { super(block); pot = (TileEntityFlowerPot) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); + contents = (pot.getItem() == null) ? null : CraftItemStack.asBukkitCopy(pot.getContents()).getData(); } - public CraftFlowerPot(Material material, TileEntityFlowerPot pot) { + public CraftFlowerPot(Material material, TileEntityFlowerPot te) { super(material); - this.pot = pot; + pot = te; + contents = (pot.getItem() == null) ? null : CraftItemStack.asBukkitCopy(pot.getContents()).getData(); } @Override @@ -34,15 +36,23 @@ public class CraftFlowerPot extends CraftBlockState implements FlowerPot { @Override public MaterialData getContents() { - return (pot.d() == null) ? null : CraftMagicNumbers.getMaterial(pot.getItem()).getNewData((byte) pot.getData()); // PAIL: rename + return contents; } @Override public void setContents(MaterialData item) { - if (item == null) { - pot.setContents(ItemStack.a); - } else { - pot.setContents(CraftItemStack.asNMSCopy(item.toItemStack())); + contents = item; + } + + @Override + public boolean update(boolean force, boolean applyPhysics) { + boolean result = super.update(force, applyPhysics); + + if (result) { + pot.setContents(contents == null ? ItemStack.a : CraftItemStack.asNMSCopy(contents.toItemStack(1))); + pot.update(); } + + return result; } }