Files
Rekkit/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
Travis Watkins 71a475f076 Don't update physics when block place is cancelled. Fixes BUKKIT-3939
When a block placement happens we currently update physics on the
attempted placement and update again if the placement is cancelled.
To correct the first one we simply set the block without applying
physics. To correct the second we have to add a new method to
BlockState that lets us update without applying physics and use
this method method when putting the block back.
2013-03-31 19:18:42 -05:00

34 lines
903 B
Java

package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityHopper;
import org.bukkit.block.Block;
import org.bukkit.block.Hopper;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftHopper extends CraftBlockState implements Hopper {
private final TileEntityHopper hopper;
public CraftHopper(final Block block) {
super(block);
hopper = (TileEntityHopper) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
}
public Inventory getInventory() {
return new CraftInventory(hopper);
}
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
hopper.update();
}
return result;
}
}