From 3df833797b6d13b328aad74f3c2f2753f0b461d8 Mon Sep 17 00:00:00 2001 From: durron597 Date: Wed, 5 Jan 2011 04:54:23 -0500 Subject: [PATCH] Beginnings of block_placed --- .../minecraft/server/NetServerHandler.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 033e36c97e..7cfe5ff5f8 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -1,9 +1,9 @@ package net.minecraft.server; - import java.util.*; import java.util.logging.Logger; import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftBlock; import org.bukkit.craftbukkit.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; @@ -289,11 +289,39 @@ implements ICommandListener { } d.e.B = false; } + + // Craftbukkit start + CraftBlock lastRightClicked; + // Craftbukkit stop public void a(Packet15Place packet15place) { ItemStack itemstack = e.an.e(); boolean flag = d.e.B = d.f.g(e.aw); + // Craftbukkit start + CraftBlock blockClicked = null; + CraftBlock blockPlaced = null; + + if (packet15place.d == 255) { + // ITEM_USE -- if we have a lastRightClicked then it could be a usable location + blockClicked = lastRightClicked; + lastRightClicked = null; + } else { + // RIGHTCLICK or BLOCK_PLACE .. or nothing + blockClicked = (CraftBlock) d.e.getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c); + // TODO: we don't have "faceclicked" concept in bukkit + // blockClicked.setFaceClicked(Block.Face.fromId(paramgt.d)); + lastRightClicked = blockClicked; + } + + // If we clicked on something then we also have a location to place the block + if (blockClicked != null && itemstack != null) { + blockPlaced = (CraftBlock) blockClicked.getFace(CraftBlock.notchToBlockFace(packet15place.d)); + // TODO: in hMod we've set the new type already. We haven't yet here. + // blockPlaced = new Block( localil.c, blockClicked.getX(), blockClicked.getY(), blockClicked.getZ()); + } + // Craftbukkit stop + if (packet15place.d == 255) { if (itemstack == null) { return;