Fixed lack of calling callEvent(event), finished Item Use
Dieser Commit ist enthalten in:
Ursprung
65c8df24b6
Commit
fab66092e2
@ -76,6 +76,7 @@ public class ItemBlock extends Item {
|
||||
boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
|
||||
|
||||
BlockPlacedEvent bpe = new BlockPlacedEvent(Type.BLOCK_PLACED, placedBlock, blockClicked, itemInHand, thePlayer, canBuild);
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(bpe);
|
||||
|
||||
if (bpe.isCancelled() || !bpe.canBuild()) {
|
||||
// Craftbukkit Undo!
|
||||
|
63
src/main/java/net/minecraft/server/ItemBoat.java
Normale Datei
63
src/main/java/net/minecraft/server/ItemBoat.java
Normale Datei
@ -0,0 +1,63 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemBoat extends Item {
|
||||
|
||||
public ItemBoat(int i) {
|
||||
super(i);
|
||||
aX = 1;
|
||||
}
|
||||
|
||||
public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
float f = 1.0F;
|
||||
float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f;
|
||||
float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f;
|
||||
double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f;
|
||||
double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H;
|
||||
double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f;
|
||||
Vec3D vec3d = Vec3D.b(d, d1, d2);
|
||||
float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F);
|
||||
float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F);
|
||||
float f5 = -MathHelper.b(-f1 * 0.01745329F);
|
||||
float f6 = MathHelper.a(-f1 * 0.01745329F);
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f6;
|
||||
float f9 = f3 * f5;
|
||||
double d3 = 5D;
|
||||
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3);
|
||||
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true);
|
||||
|
||||
if (movingobjectposition == null) {
|
||||
return itemstack;
|
||||
}
|
||||
if (movingobjectposition.a == 0) {
|
||||
int i = movingobjectposition.b;
|
||||
int j = movingobjectposition.c;
|
||||
int k = movingobjectposition.d;
|
||||
|
||||
if (!world.z) {
|
||||
// Craftbukkit start
|
||||
// Boat placement
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(movingobjectposition.e));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) return itemstack;
|
||||
|
||||
world.a(new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F));
|
||||
}
|
||||
itemstack.a--;
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
@ -65,6 +62,7 @@ public class ItemBucket extends Item {
|
||||
if (a == 0) {
|
||||
if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) {
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction);
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (!pie.isCancelled()) {
|
||||
world.d(i, j, k, 0);
|
||||
@ -75,6 +73,7 @@ public class ItemBucket extends Item {
|
||||
}
|
||||
if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction);
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (!pie.isCancelled()) {
|
||||
world.d(i, j, k, 0);
|
||||
|
65
src/main/java/net/minecraft/server/ItemFlintAndSteel.java
Normale Datei
65
src/main/java/net/minecraft/server/ItemFlintAndSteel.java
Normale Datei
@ -0,0 +1,65 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemFlintAndSteel extends Item {
|
||||
|
||||
public ItemFlintAndSteel(int i) {
|
||||
super(i);
|
||||
aX = 1;
|
||||
aY = 64;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
// Craftbukkit start - get the clicked block
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
|
||||
if (l == 0) {
|
||||
j--;
|
||||
}
|
||||
if (l == 1) {
|
||||
j++;
|
||||
}
|
||||
if (l == 2) {
|
||||
k--;
|
||||
}
|
||||
if (l == 3) {
|
||||
k++;
|
||||
}
|
||||
if (l == 4) {
|
||||
i--;
|
||||
}
|
||||
if (l == 5) {
|
||||
i++;
|
||||
}
|
||||
int i1 = world.a(i, j, k);
|
||||
|
||||
if (i1 == 0) {
|
||||
// Craftbukkit start
|
||||
// Flint and steel
|
||||
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
boolean preventLighter = pie.isCancelled();
|
||||
|
||||
if (preventLighter) {
|
||||
return false;
|
||||
} else {
|
||||
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F);
|
||||
world.d(i, j, k, Block.ar.bh);
|
||||
}
|
||||
}
|
||||
itemstack.b(1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
63
src/main/java/net/minecraft/server/ItemHoe.java
Normale Datei
63
src/main/java/net/minecraft/server/ItemHoe.java
Normale Datei
@ -0,0 +1,63 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemHoe extends Item {
|
||||
|
||||
public ItemHoe(int i, int j) {
|
||||
super(i);
|
||||
aX = 1;
|
||||
aY = 32 << j;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
int i1 = world.a(i, j, k);
|
||||
Material material = world.c(i, j + 1, k);
|
||||
|
||||
if (!material.a() && i1 == Block.u.bh || i1 == Block.v.bh) {
|
||||
// Craftbukkit start
|
||||
// Hoes
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) return false;
|
||||
|
||||
Block block = Block.aA;
|
||||
|
||||
world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.bq.c(), (block.bq.a() + 1.0F) / 2.0F, block.bq.b() * 0.8F);
|
||||
if (world.z) {
|
||||
return true;
|
||||
}
|
||||
world.d(i, j, k, block.bh);
|
||||
itemstack.b(1);
|
||||
if (world.l.nextInt(8) == 0 && i1 == Block.u.bh) {
|
||||
int j1 = 1;
|
||||
|
||||
for (int k1 = 0; k1 < j1; k1++) {
|
||||
float f = 0.7F;
|
||||
float f1 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
|
||||
float f2 = 1.2F;
|
||||
float f3 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
|
||||
EntityItem entityitem = new EntityItem(world, (float) i + f1, (float) j + f2, (float) k + f3, new ItemStack(Item.Q));
|
||||
|
||||
entityitem.c = 10;
|
||||
world.a(entityitem);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
src/main/java/net/minecraft/server/ItemMinecart.java
Normale Datei
45
src/main/java/net/minecraft/server/ItemMinecart.java
Normale Datei
@ -0,0 +1,45 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemMinecart extends Item {
|
||||
|
||||
public int a;
|
||||
|
||||
public ItemMinecart(int i, int j) {
|
||||
super(i);
|
||||
aX = 1;
|
||||
a = j;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
int i1 = world.a(i, j, k);
|
||||
|
||||
if (i1 == Block.aG.bh) {
|
||||
// Craftbukkit start
|
||||
// Minecarts
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) return false;
|
||||
|
||||
if (!world.z) {
|
||||
world.a(new EntityMinecart(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, a));
|
||||
}
|
||||
itemstack.a--;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
58
src/main/java/net/minecraft/server/ItemRedstone.java
Normale Datei
58
src/main/java/net/minecraft/server/ItemRedstone.java
Normale Datei
@ -0,0 +1,58 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemRedstone extends Item {
|
||||
|
||||
public ItemRedstone(int i) {
|
||||
super(i);
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
// Craftbukkit start get the clicked block
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
|
||||
if (l == 0) {
|
||||
j--;
|
||||
}
|
||||
if (l == 1) {
|
||||
j++;
|
||||
}
|
||||
if (l == 2) {
|
||||
k--;
|
||||
}
|
||||
if (l == 3) {
|
||||
k++;
|
||||
}
|
||||
if (l == 4) {
|
||||
i--;
|
||||
}
|
||||
if (l == 5) {
|
||||
i++;
|
||||
}
|
||||
if (!world.e(i, j, k)) {
|
||||
return false;
|
||||
}
|
||||
if (Block.av.a(world, i, j, k)) {
|
||||
// Craftbukkit start
|
||||
// Redstone
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) return false;
|
||||
|
||||
itemstack.a--;
|
||||
world.d(i, j, k, Block.av.bh);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
47
src/main/java/net/minecraft/server/ItemSeeds.java
Normale Datei
47
src/main/java/net/minecraft/server/ItemSeeds.java
Normale Datei
@ -0,0 +1,47 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemSeeds extends Item {
|
||||
|
||||
private int a;
|
||||
|
||||
public ItemSeeds(int i, int j) {
|
||||
super(i);
|
||||
a = j;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
if (l != 1) {
|
||||
return false;
|
||||
}
|
||||
int i1 = world.a(i, j, k);
|
||||
|
||||
if (i1 == Block.aA.bh) {
|
||||
// Craftbukkit start
|
||||
// Seeds
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (!pie.isCancelled()) {
|
||||
world.d(i, j + 1, k, a);
|
||||
itemstack.a--;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
src/main/java/net/minecraft/server/ItemSign.java
Normale Datei
72
src/main/java/net/minecraft/server/ItemSign.java
Normale Datei
@ -0,0 +1,72 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftBlock;
|
||||
import org.bukkit.craftbukkit.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftPlayer;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
|
||||
|
||||
public class ItemSign extends Item {
|
||||
|
||||
public ItemSign(int i) {
|
||||
super(i);
|
||||
aY = 64;
|
||||
aX = 1;
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
||||
if (l == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!world.c(i, j, k).a()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Craftbukkit - store the clicked block
|
||||
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
|
||||
if (l == 1) {
|
||||
j++;
|
||||
}
|
||||
if (l == 2) {
|
||||
k--;
|
||||
}
|
||||
if (l == 3) {
|
||||
k++;
|
||||
}
|
||||
if (l == 4) {
|
||||
i--;
|
||||
}
|
||||
if (l == 5) {
|
||||
i++;
|
||||
}
|
||||
if (!Block.aD.a(world, i, j, k)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Craftbukkit start
|
||||
// Signs
|
||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
||||
|
||||
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
||||
|
||||
if (pie.isCancelled()) return false;
|
||||
|
||||
if (l == 1) {
|
||||
world.b(i, j, k, Block.aD.bh, MathHelper.b((double) (((entityplayer.v + 180F) * 16F) / 360F) + 0.5D) & 0xf);
|
||||
} else {
|
||||
world.b(i, j, k, Block.aI.bh, l);
|
||||
}
|
||||
itemstack.a--;
|
||||
TileEntitySign tileentitysign = (TileEntitySign) world.l(i, j, k);
|
||||
|
||||
if (tileentitysign != null) {
|
||||
entityplayer.a(tileentitysign);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -342,6 +342,7 @@ implements ICommandListener {
|
||||
CraftItemStack craftItem = new CraftItemStack(itemstack);
|
||||
CraftPlayer player = new CraftPlayer(server, e);
|
||||
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, player, craftItem, blockClicked, blockFace);
|
||||
server.getPluginManager().callEvent(pie);
|
||||
|
||||
// Craftbukkit We still call this event even in spawn protection.
|
||||
// Don't call this event if using Buckets / signs
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren