geforkt von Mirrors/Paper
Major overhaul implementing PLAYER_INTERACT, removing PLAYER_ITEM, BLOCK_INTERACT, BLOCK_RIGHT_CLICK
Dieser Commit ist enthalten in:
Ursprung
bb9558adec
Commit
f33de669fb
@ -1,155 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBed extends Block {
|
||||
|
||||
public static final int[][] a = new int[][] { { 0, 1}, { -1, 0}, { 0, -1}, { 1, 0}};
|
||||
|
||||
public BlockBed(int i) {
|
||||
super(i, 134, Material.CLOTH);
|
||||
this.f();
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
int l = world.getData(i, j, k);
|
||||
|
||||
if (!d(l)) {
|
||||
int i1 = c(l);
|
||||
|
||||
i += a[i1][0];
|
||||
k += a[i1][1];
|
||||
if (world.getTypeId(i, j, k) != this.id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
l = world.getData(i, j, k);
|
||||
}
|
||||
|
||||
// CraftBukkit start - Interact Bed
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Event.Type eventType = Event.Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (f(l)) {
|
||||
entityhuman.a("tile.bed.occupied");
|
||||
return true;
|
||||
} else if (entityhuman.a(i, j, k)) {
|
||||
a(world, i, j, k, true);
|
||||
return true;
|
||||
} else {
|
||||
entityhuman.a("tile.bed.noSleep");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public int a(int i, int j) {
|
||||
if (i == 0) {
|
||||
return Block.WOOD.textureId;
|
||||
} else {
|
||||
int k = c(j);
|
||||
int l = BedBlockTextures.c[k][i];
|
||||
|
||||
return d(j) ? (l == 2 ? this.textureId + 2 + 16 : (l != 5 && l != 4 ? this.textureId + 1 : this.textureId + 1 + 16)) : (l == 3 ? this.textureId - 1 + 16 : (l != 5 && l != 4 ? this.textureId : this.textureId + 16));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
|
||||
this.f();
|
||||
}
|
||||
|
||||
public void a(World world, int i, int j, int k, int l) {
|
||||
int i1 = world.getData(i, j, k);
|
||||
int j1 = c(i1);
|
||||
|
||||
if (d(i1)) {
|
||||
if (world.getTypeId(i - a[j1][0], j, k - a[j1][1]) != this.id) {
|
||||
world.e(i, j, k, 0);
|
||||
}
|
||||
} else if (world.getTypeId(i + a[j1][0], j, k + a[j1][1]) != this.id) {
|
||||
world.e(i, j, k, 0);
|
||||
if (!world.isStatic) {
|
||||
this.b_(world, i, j, k, i1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int a(int i, Random random) {
|
||||
return d(i) ? 0 : Item.BED.id;
|
||||
}
|
||||
|
||||
private void f() {
|
||||
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
|
||||
}
|
||||
|
||||
public static int c(int i) {
|
||||
return i & 3;
|
||||
}
|
||||
|
||||
public static boolean d(int i) {
|
||||
return (i & 8) != 0;
|
||||
}
|
||||
|
||||
public static boolean f(int i) {
|
||||
return (i & 4) != 0;
|
||||
}
|
||||
|
||||
public static void a(World world, int i, int j, int k, boolean flag) {
|
||||
int l = world.getData(i, j, k);
|
||||
|
||||
if (flag) {
|
||||
l |= 4;
|
||||
} else {
|
||||
l &= -5;
|
||||
}
|
||||
|
||||
world.c(i, j, k, l);
|
||||
}
|
||||
|
||||
public static ChunkCoordinates g(World world, int i, int j, int k, int l) {
|
||||
int i1 = world.getData(i, j, k);
|
||||
int j1 = c(i1);
|
||||
|
||||
for (int k1 = 0; k1 <= 1; ++k1) {
|
||||
int l1 = i - a[j1][0] * k1 - 1;
|
||||
int i2 = k - a[j1][1] * k1 - 1;
|
||||
int j2 = l1 + 2;
|
||||
int k2 = i2 + 2;
|
||||
|
||||
for (int l2 = l1; l2 <= j2; ++l2) {
|
||||
for (int i3 = i2; i3 <= k2; ++i3) {
|
||||
if (world.d(l2, j - 1, i3) && world.isEmpty(l2, j, i3) && world.isEmpty(l2, j + 1, i3)) {
|
||||
if (l <= 0) {
|
||||
return new ChunkCoordinates(l2, j, i3);
|
||||
}
|
||||
|
||||
--l;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ChunkCoordinates(i, j + 1, k);
|
||||
}
|
||||
}
|
@ -6,9 +6,6 @@ import java.util.Random;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@ -126,21 +123,6 @@ public class BlockButton extends Block {
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
// CraftBukkit start - Interact Button
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
int l = world.getData(i, j, k);
|
||||
int i1 = l & 7;
|
||||
int j1 = 8 - (l & 8);
|
||||
@ -149,6 +131,10 @@ public class BlockButton extends Block {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
|
||||
int old = (j1 != 8) ? 1 : 0;
|
||||
int current = (j1 == 8) ? 1 : 0;
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
||||
|
@ -1,141 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockChest extends BlockContainer {
|
||||
|
||||
private Random a = new Random();
|
||||
|
||||
protected BlockChest(int i) {
|
||||
super(i, Material.WOOD);
|
||||
this.textureId = 26;
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId));
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k) {
|
||||
int l = 0;
|
||||
|
||||
if (world.getTypeId(i - 1, j, k) == this.id) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getTypeId(i + 1, j, k) == this.id) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getTypeId(i, j, k - 1) == this.id) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getTypeId(i, j, k + 1) == this.id) {
|
||||
++l;
|
||||
}
|
||||
|
||||
return l > 1 ? false : (this.g(world, i - 1, j, k) ? false : (this.g(world, i + 1, j, k) ? false : (this.g(world, i, j, k - 1) ? false : !this.g(world, i, j, k + 1))));
|
||||
}
|
||||
|
||||
private boolean g(World world, int i, int j, int k) {
|
||||
return world.getTypeId(i, j, k) != this.id ? false : (world.getTypeId(i - 1, j, k) == this.id ? true : (world.getTypeId(i + 1, j, k) == this.id ? true : (world.getTypeId(i, j, k - 1) == this.id ? true : world.getTypeId(i, j, k + 1) == this.id)));
|
||||
}
|
||||
|
||||
public void b(World world, int i, int j, int k) {
|
||||
TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(i, j, k);
|
||||
|
||||
for (int l = 0; l < tileentitychest.m_(); ++l) {
|
||||
ItemStack itemstack = tileentitychest.c_(l);
|
||||
|
||||
if (itemstack != null) {
|
||||
float f = this.a.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.a.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.a.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.count > 0) {
|
||||
int i1 = this.a.nextInt(21) + 10;
|
||||
|
||||
if (i1 > itemstack.count) {
|
||||
i1 = itemstack.count;
|
||||
}
|
||||
|
||||
itemstack.count -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.h()));
|
||||
float f3 = 0.05F;
|
||||
|
||||
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
|
||||
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
|
||||
world.a((Entity) entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.b(world, i, j, k);
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
Object object = (TileEntityChest) world.getTileEntity(i, j, k);
|
||||
|
||||
if (world.d(i, j + 1, k)) {
|
||||
return true;
|
||||
} else if (world.getTypeId(i - 1, j, k) == this.id && world.d(i - 1, j + 1, k)) {
|
||||
return true;
|
||||
} else if (world.getTypeId(i + 1, j, k) == this.id && world.d(i + 1, j + 1, k)) {
|
||||
return true;
|
||||
} else if (world.getTypeId(i, j, k - 1) == this.id && world.d(i, j + 1, k - 1)) {
|
||||
return true;
|
||||
} else if (world.getTypeId(i, j, k + 1) == this.id && world.d(i, j + 1, k + 1)) {
|
||||
return true;
|
||||
} else {
|
||||
if (world.getTypeId(i - 1, j, k) == this.id) {
|
||||
object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i - 1, j, k), (IInventory) object);
|
||||
}
|
||||
|
||||
if (world.getTypeId(i + 1, j, k) == this.id) {
|
||||
object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i + 1, j, k));
|
||||
}
|
||||
|
||||
if (world.getTypeId(i, j, k - 1) == this.id) {
|
||||
object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i, j, k - 1), (IInventory) object);
|
||||
}
|
||||
|
||||
if (world.getTypeId(i, j, k + 1) == this.id) {
|
||||
object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i, j, k + 1));
|
||||
}
|
||||
|
||||
if (world.isStatic) {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Chest
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return true;
|
||||
// CraftBukkit end
|
||||
|
||||
entityhuman.a((IInventory) object);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected TileEntity a_() {
|
||||
return new TileEntityChest();
|
||||
}
|
||||
}
|
@ -1,12 +1,6 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
|
||||
public class BlockDispenser extends BlockContainer {
|
||||
|
||||
@ -62,21 +56,6 @@ public class BlockDispenser extends BlockContainer {
|
||||
if (world.isStatic) {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Dispenser
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);
|
||||
|
||||
entityhuman.a(tileentitydispenser);
|
||||
|
@ -1,9 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockDoor extends Block {
|
||||
|
||||
@ -179,6 +182,7 @@ public class BlockDoor extends Block {
|
||||
int power = block.getBlockPower();
|
||||
int powerTop = blockTop.getBlockPower();
|
||||
if (powerTop > power) power = powerTop;
|
||||
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, power);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
this.a(world, i, j, k, eventRedstone.getNewCurrent() > 0);
|
||||
|
@ -1,126 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockFurnace extends BlockContainer {
|
||||
|
||||
private final boolean a;
|
||||
|
||||
protected BlockFurnace(int i, boolean flag) {
|
||||
super(i, Material.STONE);
|
||||
this.a = flag;
|
||||
this.textureId = 45;
|
||||
}
|
||||
|
||||
public int a(int i, Random random) {
|
||||
return Block.FURNACE.id;
|
||||
}
|
||||
|
||||
public void e(World world, int i, int j, int k) {
|
||||
super.e(world, i, j, k);
|
||||
this.g(world, i, j, k);
|
||||
}
|
||||
|
||||
private void g(World world, int i, int j, int k) {
|
||||
int l = world.getTypeId(i, j, k - 1);
|
||||
int i1 = world.getTypeId(i, j, k + 1);
|
||||
int j1 = world.getTypeId(i - 1, j, k);
|
||||
int k1 = world.getTypeId(i + 1, j, k);
|
||||
byte b0 = 3;
|
||||
|
||||
if (Block.o[l] && !Block.o[i1]) {
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (Block.o[i1] && !Block.o[l]) {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (Block.o[j1] && !Block.o[k1]) {
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
if (Block.o[k1] && !Block.o[j1]) {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
world.c(i, j, k, b0);
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId));
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
if (world.isStatic) {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Furnace
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
|
||||
|
||||
entityhuman.a(tileentityfurnace);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(boolean flag, World world, int i, int j, int k) {
|
||||
int l = world.getData(i, j, k);
|
||||
TileEntity tileentity = world.getTileEntity(i, j, k);
|
||||
|
||||
if (flag) {
|
||||
world.e(i, j, k, Block.BURNING_FURNACE.id);
|
||||
} else {
|
||||
world.e(i, j, k, Block.FURNACE.id);
|
||||
}
|
||||
|
||||
world.c(i, j, k, l);
|
||||
world.setTileEntity(i, j, k, tileentity);
|
||||
}
|
||||
|
||||
protected TileEntity a_() {
|
||||
return new TileEntityFurnace();
|
||||
}
|
||||
|
||||
public void a(World world, int i, int j, int k, EntityLiving entityliving) {
|
||||
int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0) {
|
||||
world.c(i, j, k, 2);
|
||||
}
|
||||
|
||||
if (l == 1) {
|
||||
world.c(i, j, k, 5);
|
||||
}
|
||||
|
||||
if (l == 2) {
|
||||
world.c(i, j, k, 3);
|
||||
}
|
||||
|
||||
if (l == 3) {
|
||||
world.c(i, j, k, 4);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockJukeBox extends Block {
|
||||
|
||||
protected BlockJukeBox(int i, int j) {
|
||||
super(i, j, Material.WOOD);
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return this.textureId + (i == 1 ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
int l = world.getData(i, j, k);
|
||||
|
||||
if (l > 0) {
|
||||
// CraftBukkit start - Interact Jukebox
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
this.e(world, i, j, k, l);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void e(World world, int i, int j, int k, int l) {
|
||||
world.a((String) null, i, j, k);
|
||||
world.c(i, j, k, 0);
|
||||
int i1 = Item.GOLD_RECORD.id + l - 1;
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.k.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (world.k.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
|
||||
double d2 = (double) (world.k.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
|
||||
|
||||
entityitem.c = 10;
|
||||
world.a((Entity) entityitem);
|
||||
}
|
||||
|
||||
public void a(World world, int i, int j, int k, int l, float f) {
|
||||
if (!world.isStatic) {
|
||||
if (l > 0) {
|
||||
this.e(world, i, j, k, l);
|
||||
}
|
||||
|
||||
super.a(world, i, j, k, l, f);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,9 +4,6 @@ package net.minecraft.server;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@ -124,29 +121,15 @@ public class BlockLever extends Block {
|
||||
if (world.isStatic) {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Lever
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
// The client updates the doors before the server does it's thing.
|
||||
// Forcibly send correct data.
|
||||
if (event.isCancelled()) {
|
||||
((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
int l = world.getData(i, j, k);
|
||||
int i1 = l & 7;
|
||||
int j1 = 8 - (l & 8);
|
||||
|
||||
// CraftBukkit start
|
||||
// CraftBukkit start - Interact Lever
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
|
||||
int old = (j1 != 8) ? 1 : 0;
|
||||
int current = (j1 == 8) ? 1 : 0;
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
||||
|
@ -7,10 +7,10 @@ import java.util.Random;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockPressurePlate extends Block {
|
||||
@ -96,20 +96,11 @@ public class BlockPressurePlate extends Block {
|
||||
}
|
||||
|
||||
// CraftBukkit start - Interact Pressure Plate
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
|
||||
if (flag != flag1) {
|
||||
if (flag1) {
|
||||
for (Object object: list) {
|
||||
if (object != null && object instanceof EntityLiving) {
|
||||
EntityLiving entity = (EntityLiving) object;
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
org.bukkit.entity.LivingEntity who = (LivingEntity) entity.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (object != null && object instanceof EntityHuman) {
|
||||
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -118,6 +109,10 @@ public class BlockPressurePlate extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
|
||||
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 1 : 0, flag1 ? 1 : 0);
|
||||
server.getPluginManager().callEvent(eventRedstone);
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.BlockInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class BlockWorkbench extends Block {
|
||||
|
||||
protected BlockWorkbench(int i) {
|
||||
super(i, Material.WOOD);
|
||||
this.textureId = 59;
|
||||
}
|
||||
|
||||
public int a(int i) {
|
||||
return i == 1 ? this.textureId - 16 : (i == 0 ? Block.WOOD.a(0) : (i != 2 && i != 4 ? this.textureId : this.textureId + 1));
|
||||
}
|
||||
|
||||
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
|
||||
if (world.isStatic) {
|
||||
return true;
|
||||
} else {
|
||||
// CraftBukkit start - Interact Workbench
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
Type eventType = Type.BLOCK_INTERACT;
|
||||
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
|
||||
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
|
||||
|
||||
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
entityhuman.b(i, j, k);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ItemBoat extends Item {
|
||||
@ -46,17 +41,7 @@ public class ItemBoat extends Item {
|
||||
|
||||
if (!world.isStatic) {
|
||||
// CraftBukkit start - Boat placement
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer craftServer = ((WorldServer) world).getServer();
|
||||
|
||||
Type eventType = Type.PLAYER_ITEM;
|
||||
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
|
||||
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
|
||||
BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
|
||||
|
||||
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.e, itemstack);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return itemstack;
|
||||
|
@ -1,8 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ItemInWorldManager {
|
||||
@ -51,9 +55,18 @@ public class ItemInWorldManager {
|
||||
this.d = this.j;
|
||||
int l = this.b.getTypeId(i, j, k);
|
||||
|
||||
if (l > 0) {
|
||||
// CraftBukkit start
|
||||
// Swings at air do *NOT* exist.
|
||||
if (l <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.a, Action.LEFT_CLICK_BLOCK , i, j, k, -1, this.a.inventory.b());
|
||||
|
||||
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||
Block.byId[l].b(this.b, i, j, k, this.a);
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (l > 0 && Block.byId[l].a(this.a) >= 1.0F) {
|
||||
this.d(i, j, k);
|
||||
@ -157,6 +170,18 @@ public class ItemInWorldManager {
|
||||
public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) {
|
||||
int i1 = world.getTypeId(i, j, k);
|
||||
|
||||
return i1 > 0 && Block.byId[i1].a(world, i, j, k, entityhuman) ? true : (itemstack == null ? false : itemstack.a(entityhuman, world, i, j, k, l));
|
||||
// CraftBukkit start - Interact
|
||||
boolean result = false;
|
||||
if (i1 > 0) {
|
||||
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack);
|
||||
if (event.useInteractedBlock() != Event.Result.DENY) {
|
||||
result = Block.byId[i1].a(world, i, j, k, entityhuman);
|
||||
}
|
||||
if (itemstack != null && event.useItemInHand() != Event.Result.DENY && (!result || event.useItemInHand() == Event.Result.ALLOW)) {
|
||||
result = itemstack.a(entityhuman, world, i, j, k, l);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ItemMinecart extends Item {
|
||||
@ -27,17 +22,7 @@ public class ItemMinecart extends Item {
|
||||
if (i1 == Block.RAILS.id) {
|
||||
if (!world.isStatic) {
|
||||
// CraftBukkit start - Minecarts
|
||||
CraftWorld craftWorld = ((WorldServer) world).getWorld();
|
||||
CraftServer craftServer = ((WorldServer) world).getServer();
|
||||
|
||||
Type eventType = Type.PLAYER_ITEM;
|
||||
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
|
||||
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
|
||||
BlockFace blockFace = CraftBlock.notchToBlockFace(l);
|
||||
|
||||
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
|
@ -34,6 +34,7 @@ public class ItemSeeds extends Item {
|
||||
return false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
--itemstack.count;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.command.CommandException;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.TextWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -93,6 +94,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
this.b.c();
|
||||
this.d.f.a((Packet) (new Packet3Chat( event.getLeaveMessage() )));
|
||||
// CraftBukkit end
|
||||
|
||||
this.d.f.c(this.e);
|
||||
this.c = true;
|
||||
}
|
||||
@ -401,7 +403,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
BlockFace blockFace = BlockFace.SELF;
|
||||
|
||||
if (packet15place.d == 255) {
|
||||
// CraftBukkit ITEM_USE -- if we have a lastRightClicked then it could be a usable location
|
||||
// CraftBukkit -- if we have a lastRightClicked then it could be a usable location
|
||||
if ((packet15place.e != null && packet15place.e.id == lastMaterial) || lastMaterial == 0) {
|
||||
blockClicked = this.lastRightClicked;
|
||||
blockFace = this.lastRightClickedFace;
|
||||
@ -410,7 +412,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
this.lastRightClickedFace = null;
|
||||
this.lastMaterial = 0;
|
||||
} else {
|
||||
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
|
||||
// CraftBukkit -- RIGHTCLICK or BLOCK_PLACE .. or nothing
|
||||
blockClicked = (CraftBlock) ((WorldServer) e.world).getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
|
||||
blockFace = CraftBlock.notchToBlockFace(packet15place.d);
|
||||
|
||||
@ -430,13 +432,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
Type eventType = Type.PLAYER_ITEM;
|
||||
Player who = (this.e == null) ? null : (Player) this.e.getBukkitEntity();
|
||||
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
|
||||
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
|
||||
|
||||
// CraftBukkit start - Check if we can actually do something over this large a distance
|
||||
if (blockClicked != null && blockFace != null) {
|
||||
CraftBlock block = (CraftBlock) blockClicked.getFace(blockFace);
|
||||
Location eyeLoc = getPlayer().getEyeLocation();
|
||||
@ -445,6 +441,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
}
|
||||
}
|
||||
|
||||
PlayerInteractEvent event = null;
|
||||
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
|
||||
// CraftBukkit We still call this event even in spawn protection.
|
||||
// Don't call this event if using Buckets / signs
|
||||
switch (itemInHand.getType()) {
|
||||
@ -454,15 +453,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
case LAVA_BUCKET:
|
||||
break;
|
||||
default:
|
||||
server.getPluginManager().callEvent(event);
|
||||
event = CraftEventFactory.callPlayerInteractEvent(this.e, Action.RIGHT_CLICK_BLOCK, packet15place.a, packet15place.b, packet15place.c, packet15place.d, itemstack);
|
||||
}
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (event != null && !event.isCancelled()) {
|
||||
int itemstackAmount = itemstack.count;
|
||||
this.e.c.a(this.e, this.e.world, itemstack);
|
||||
|
||||
// CraftBukkit notch decrements the counter by 1 in the above method with food,
|
||||
// snowballs and so forth, but he does it in a place that doesnt cause the
|
||||
// snowballs and so forth, but he does it in a place that doesn't cause the
|
||||
// inventory update packet to get sent
|
||||
always = (itemstack.count != itemstackAmount);
|
||||
}
|
||||
@ -483,14 +482,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
}
|
||||
|
||||
// CraftBukkit start - spawn protection moved to ItemBlock!!!
|
||||
// Check if we can actually do something over this large a distance
|
||||
Location eyeLoc = getPlayer().getEyeLocation();
|
||||
if (Math.pow(eyeLoc.getX() - i, 2) + Math.pow(eyeLoc.getY() - j, 2) + Math.pow(eyeLoc.getZ() - k, 2) > PLACE_DISTANCE_SQUARED) {
|
||||
return;
|
||||
}
|
||||
CraftItemStack craftItem = new CraftItemStack(itemstack);
|
||||
Player player = getPlayer();
|
||||
BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICK, blockClicked, blockFace, craftItem, player);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
this.e.c.a(this.e, this.e.world, itemstack, i, j, k, l);
|
||||
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world)));
|
||||
@ -689,7 +685,30 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
|
||||
public void a(Packet18ArmAnimation packet18armanimation) {
|
||||
if (packet18armanimation.b == 1) {
|
||||
// CraftBukkit start - Arm swing animation
|
||||
// CraftBukkit -- raytrace to look for 'rogue armswings'
|
||||
float f = 1.0F;
|
||||
float f1 = this.e.lastPitch + (this.e.pitch - this.e.lastPitch) * f;
|
||||
float f2 = this.e.lastYaw + (this.e.yaw - this.e.lastYaw) * f;
|
||||
double d0 = this.e.lastX + (this.e.locX - this.e.lastX) * (double) f;
|
||||
double d1 = this.e.lastY + (this.e.locY - this.e.lastY) * (double) f + 1.62D - (double) this.e.height;
|
||||
double d2 = this.e.lastZ + (this.e.locZ - this.e.lastZ) * (double) f;
|
||||
Vec3D vec3d = Vec3D.b(d0, d1, d2);
|
||||
|
||||
float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
|
||||
float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
|
||||
float f5 = -MathHelper.b(-f1 * 0.017453292F);
|
||||
float f6 = MathHelper.a(-f1 * 0.017453292F);
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = 5.0D;
|
||||
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
MovingObjectPosition movingobjectposition = this.e.world.a(vec3d, vec3d1, true);
|
||||
|
||||
if (movingobjectposition == null || movingobjectposition.a != EnumMovingObjectType.TILE) {
|
||||
CraftEventFactory.callPlayerInteractEvent(this.e, Action.LEFT_CLICK_AIR, this.e.inventory.b());
|
||||
}
|
||||
|
||||
// Arm swing animation
|
||||
Player player = getPlayer();
|
||||
PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
@ -17,10 +17,12 @@ import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class CraftEventFactory {
|
||||
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
|
||||
@ -100,4 +102,46 @@ public class CraftEventFactory {
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Player Interact event
|
||||
*/
|
||||
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
|
||||
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack);
|
||||
}
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
|
||||
CraftWorld craftWorld = (CraftWorld) player.getWorld();
|
||||
CraftServer craftServer = (CraftServer) player.getServer();
|
||||
|
||||
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
|
||||
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
|
||||
|
||||
if (clickedY == 255) {
|
||||
blockClicked = null;
|
||||
switch (action) {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
action = Action.LEFT_CLICK_AIR;
|
||||
break;
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
action = Action.RIGHT_CLICK_AIR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
|
||||
itemInHand = null;
|
||||
}
|
||||
|
||||
PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren