blob: 6b4ef8ad3aa483ad504a68c839bb45e1ca996b5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockDropper;
import net.minecraft.server.Blocks;
import net.minecraft.server.TileEntityDropper;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dropper;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftDropper extends CraftBlockState implements Dropper {
private final CraftWorld world;
private final TileEntityDropper dropper;
public CraftDropper(final Block block) {
super(block);
world = (CraftWorld) block.getWorld();
dropper = (TileEntityDropper) world.getTileEntityAt(getX(), getY(), getZ());
}
public Inventory getInventory() {
return new CraftInventory(dropper);
}
public void drop() {
Block block = getBlock();
if (block.getType() == Material.DROPPER) {
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
drop.dispense(world.getHandle(), getX(), getY(), getZ());
}
}
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
dropper.update();
}
return result;
}
}
|