removed some potential bugs from some items

Dieser Commit ist enthalten in:
Andrew Ardill 2011-01-24 00:10:53 +11:00
Ursprung a809e4e6e3
Commit ab3412e878
3 geänderte Dateien mit 17 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -3,8 +3,8 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Server;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
@ -24,6 +24,11 @@ public class ItemFlintAndSteel extends Item {
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
// CraftBukkit - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (l == 0) { if (l == 0) {
j--; j--;
} }
@ -46,24 +51,20 @@ public class ItemFlintAndSteel extends Item {
if (i1 == 0) { if (i1 == 0) {
// CraftBukkit start - Flint and steel // CraftBukkit start - Flint and steel
Server server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
Type eventType = Type.PLAYER_ITEM; Type eventType = Type.PLAYER_ITEM;
Player thePlayer = (Player) entityplayer.getBukkitEntity(); Player thePlayer = (Player) entityplayer.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = cworld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(l); BlockFace blockFace = CraftBlock.notchToBlockFace(l);
PlayerItemEvent pie = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace); PlayerItemEvent pie = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace);
server.getPluginManager().callEvent(pie); craftServer.getPluginManager().callEvent(pie);
boolean preventLighter = pie.isCancelled(); boolean preventLighter = pie.isCancelled();
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL; IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL;
BlockIgniteEvent bie = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer); BlockIgniteEvent bie = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer);
server.getPluginManager().callEvent(bie); craftServer.getPluginManager().callEvent(bie);
boolean preventFire = bie.isCancelled(); boolean preventFire = bie.isCancelled();

Datei anzeigen

@ -19,6 +19,11 @@ public class ItemRedstone extends Item {
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
// CraftBukkit - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (l == 0) { if (l == 0) {
j--; j--;
} }
@ -42,13 +47,9 @@ public class ItemRedstone extends Item {
} }
if (Block.av.a(world, i, j, k)) { if (Block.av.a(world, i, j, k)) {
// CraftBukkit start - Redstone // CraftBukkit start - Redstone
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM; Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity(); Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockface = CraftBlock.notchToBlockFace(1); BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface); PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);

Datei anzeigen

@ -28,6 +28,9 @@ public class ItemSign extends Item {
} }
// CraftBukkit - store the clicked block // CraftBukkit - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (l == 1) { if (l == 1) {
j++; j++;
@ -50,13 +53,9 @@ public class ItemSign extends Item {
// CraftBukkit start // CraftBukkit start
// Signs // Signs
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM; Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity(); Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockface = CraftBlock.notchToBlockFace(1); BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface); PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);