From e5d7a4602952369bf6f70f00bbd4f635e02ad36b Mon Sep 17 00:00:00 2001 From: Taylor Kelly Date: Mon, 10 Jan 2011 09:57:47 +0800 Subject: [PATCH] - --- pom.xml | 2 +- .../minecraft/server/ItemInWorldManager.java | 20 ++++++++++--------- .../minecraft/server/NetServerHandler.java | 15 +++++++++++++- .../craftbukkit/CraftInventoryPlayer.java | 9 +++++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index aa623a25b1..229ed354fa 100644 --- a/pom.xml +++ b/pom.xml @@ -67,4 +67,4 @@ - + \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 6b285e1bb5..011ace1be1 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -3,15 +3,17 @@ package net.minecraft.server; public class ItemInWorldManager { - private World b; - public EntityPlayer a; - private float c; - private float d; - private int e; - private float f; - private int g; - private int h; - private int i; + private World b; //currWorld + public EntityPlayer a; //currPlayer + private float c; // not used? + //Craftbukkit start + public float d; // blockDamage (0 up to 1) //Craftbukkit - Made public to get damage + //Craftbukkit stop + private int e; // funny counter + private float f; // blockHits + private int g; //posX + private int h; //posY + private int i; //posZ public ItemInWorldManager(World world) { d = 0.0F; diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 355dc77ed6..87df11b41b 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -233,6 +233,13 @@ public class NetServerHandler extends NetHandler e.a.b(new Packet13PlayerLookMove(d1, d2 + 1.6200000047683716D, d2, d3, f1, f2, false)); } + // CraftBukkit start + // Get position of last block hit for BlockDamageLevel.STOPPED + private int lastX; + private int lastY; + private int lastZ; + // Craftbukkit stop + public void a(Packet14BlockDig packet14blockdig) { if (packet14blockdig.e == 4) { e.L(); @@ -296,6 +303,9 @@ public class NetServerHandler extends NetHandler } } } else if (packet14blockdig.e == 2) { + // Get last block that the player hit + // Otherwise the block is a Bedrock @(0,0,0) + block = (CraftBlock) player.getWorld().getBlockAt(lastX, lastY, lastZ); BlockDamagedEvent event = new BlockDamagedEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STOPPED, player); server.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -326,8 +336,11 @@ public class NetServerHandler extends NetHandler e.a.b(new Packet53BlockChange(l, i1, j1, d.e)); } } + lastX = l; + lastY = i1; + lastZ = j1; // Craftbukkit stop - + d.e.B = false; } // Craftbukkit start - store the last block right clicked and what type it was diff --git a/src/main/java/org/bukkit/craftbukkit/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftInventoryPlayer.java index 576661e2ff..b49d6d9719 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftInventoryPlayer.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit; +import java.util.ArrayList; import net.minecraft.server.InventoryPlayer; import org.bukkit.ItemStack; @@ -14,15 +15,15 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent return (InventoryPlayer) inventory; } - public CraftItemStack[] getArmorContents() { + public ArrayList getArmorContents() { net.minecraft.server.ItemStack[] mcItems = getInventory().getArmorContents(); - CraftItemStack[] items = new CraftItemStack[mcItems.length]; + ArrayList ret = new ArrayList(); for (int i = 0; i < mcItems.length; i++ ) { - items[i] = new CraftItemStack(mcItems[i]); + ret.add(new CraftItemStack(mcItems[i])); } - return items; + return ret; } public int getSize() {