geforkt von Mirrors/Paper
[Bleeding] Added BlockGrowEvent. Addresses BUKKIT-104
By: Feildmaster <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Ursprung
bed15aa413
Commit
0126ce2b16
@ -80,9 +80,11 @@ public class CraftBlockState implements BlockState {
|
||||
}
|
||||
|
||||
public boolean setTypeId(final int type) {
|
||||
if (this.type != type) {
|
||||
this.type = type;
|
||||
|
||||
createData((byte) 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,7 +128,7 @@ public class CraftBlockState implements BlockState {
|
||||
}
|
||||
|
||||
private void createData(final byte data) {
|
||||
Material mat = Material.getMaterial(type);
|
||||
Material mat = getType();
|
||||
if (mat == null || mat.getData() == null) {
|
||||
this.data = new MaterialData(type, data);
|
||||
} else {
|
||||
@ -142,8 +144,8 @@ public class CraftBlockState implements BlockState {
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
public void setData(byte data) {
|
||||
createData(data);
|
||||
public void setRawData(byte data) {
|
||||
this.data.setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +52,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@ -438,4 +439,18 @@ public class CraftEventFactory {
|
||||
|
||||
return !projectile.doesBounce();
|
||||
}
|
||||
|
||||
public static void handleBlockGrowEvent(World world, int x, int y, int z, int type, int data) {
|
||||
Block block = world.getWorld().getBlockAt(x, y, z);
|
||||
CraftBlockState state = (CraftBlockState) block.getState();
|
||||
state.setTypeId(type);
|
||||
state.setRawData((byte) data);
|
||||
|
||||
BlockGrowEvent event = new BlockGrowEvent(block, state);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren