summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-04-15 18:01:44 +1000
committermd_5 <git@md-5.net>2017-04-15 18:01:44 +1000
commitac405c3cd4fe9924e4115dd55f430597dde61c7a (patch)
treeb84b07ce603f6d64b932f45a8fb553a1a42e67e9
parent1ac133ecc52da74c6f87e3cf308fc4ad39df4518 (diff)
downloadcraftbukkit-ac405c3cd4fe9924e4115dd55f430597dde61c7a.tar
craftbukkit-ac405c3cd4fe9924e4115dd55f430597dde61c7a.tar.gz
craftbukkit-ac405c3cd4fe9924e4115dd55f430597dde61c7a.tar.lz
craftbukkit-ac405c3cd4fe9924e4115dd55f430597dde61c7a.tar.xz
craftbukkit-ac405c3cd4fe9924e4115dd55f430597dde61c7a.zip
Fix some blockstate consistency issues.
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftDaylightDetector.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java26
6 files changed, 25 insertions, 15 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
index f0b1703d..7bf72699 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 09fddf4a..5d83155a 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 a6253bce..9bbc7905 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 7b909e34..c3c3bd08 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 f43a9a36..b970727c 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 a22fed36..e6a5bc1a 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;
}
}