geforkt von Mirrors/Paper
Added CraftDispenser.dispense()
By: Dinnerbone <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
9291fe9e98
Commit
0c1b5191ad
@ -1,40 +1,57 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.server.TileEntityDispenser;
|
import java.util.Random;
|
||||||
import org.bukkit.block.Block;
|
import net.minecraft.server.BlockDispenser;
|
||||||
import org.bukkit.block.Dispenser;
|
import net.minecraft.server.TileEntityDispenser;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.block.Dispenser;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
/**
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
* Represents a dispenser.
|
import org.bukkit.inventory.Inventory;
|
||||||
*
|
|
||||||
* @author sk89q
|
/**
|
||||||
*/
|
* Represents a dispenser.
|
||||||
public class CraftDispenser extends CraftBlockState implements Dispenser {
|
*
|
||||||
private final CraftWorld world;
|
* @author sk89q
|
||||||
private final TileEntityDispenser dispenser;
|
*/
|
||||||
|
public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||||
public CraftDispenser(final Block block) {
|
private final CraftWorld world;
|
||||||
super(block);
|
private final TileEntityDispenser dispenser;
|
||||||
|
|
||||||
world = (CraftWorld)block.getWorld();
|
public CraftDispenser(final Block block) {
|
||||||
dispenser = (TileEntityDispenser)world.getTileEntityAt(getX(), getY(), getZ());
|
super(block);
|
||||||
}
|
|
||||||
|
world = (CraftWorld)block.getWorld();
|
||||||
public Inventory getInventory() {
|
dispenser = (TileEntityDispenser)world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
return new CraftInventory(dispenser);
|
}
|
||||||
}
|
|
||||||
|
public Inventory getInventory() {
|
||||||
@Override
|
return new CraftInventory(dispenser);
|
||||||
public boolean update(boolean force) {
|
}
|
||||||
boolean result = super.update(force);
|
|
||||||
|
public boolean dispense() {
|
||||||
if (result) {
|
Block block = getBlock();
|
||||||
dispenser.d();
|
|
||||||
}
|
synchronized (block) {
|
||||||
|
if (block.getType() == Material.DISPENSER) {
|
||||||
return result;
|
BlockDispenser dispense = (BlockDispenser)net.minecraft.server.Block.DISPENSER;
|
||||||
}
|
dispense.b(world.getHandle(), getX(), getY(), getZ(), new Random());
|
||||||
}
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(boolean force) {
|
||||||
|
boolean result = super.update(force);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
dispenser.d();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren