diff options
author | bloodshot <jdroque@gmail.com> | 2014-01-06 00:17:16 -0500 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2014-04-23 21:25:55 -0600 |
commit | 576758bc55941e673b1c4bf5727a1e1329ef29cd (patch) | |
tree | b3e114f8d5852efafe2827a9a392d11a7ce519f2 /src/main/java/net/minecraft/server/ItemDye.java | |
parent | de97b62b8945ec7a05c7b6813a6317606f46faaf (diff) | |
download | craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.gz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.lz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.tar.xz craftbukkit-576758bc55941e673b1c4bf5727a1e1329ef29cd.zip |
Refactored BlockPlaceEvent and BlockChangeDelegate. Adds BUKKIT-5558
23 classes have been removed as they are no longer needed using the new
capture logic. This should help quite a bit with future MC updates.
BlockPlaceEvent Refactor
Before calling Item.interactWith, a recording flag is turned on for
setTypeAndData to capture a blockstate for each block that attempts to be set.
When a block place event is cancelled, the recorded blockstate, stack
size, and metadata will revert back to the captured state. If the event is
not cancelled, a notification will be sent to clients and block physics
will be updated.
BlockChangeDelegate Refactor
Now that we have the ability to capture blockstates through world, there
is no need to modify world gen classes with BlockChangeDelegate. Instead
we will simply capture blocks during world generation in order to "replay"
all of the captured blockstates to send back to delegates.
StructureGrowDelegate and BlockSapling.TreeGenerator have also been
removed as part of this change. BlockSapling and BlockMushroom will
capture blockstates the same as block placement and revert back any grow
events if needed.
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemDye.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemDye.java | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/src/main/java/net/minecraft/server/ItemDye.java b/src/main/java/net/minecraft/server/ItemDye.java index 064e9685..156af8e3 100644 --- a/src/main/java/net/minecraft/server/ItemDye.java +++ b/src/main/java/net/minecraft/server/ItemDye.java @@ -1,9 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.event.entity.SheepDyeWoolEvent; -// CraftBukkit end +import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit public class ItemDye extends Item { @@ -24,12 +21,11 @@ public class ItemDye extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { if (itemstack.getData() == 15) { - if (a(itemstack, world, i, j, k, entityhuman)) { // CraftBukkit - pass entity for StructureGrowEvent + if (a(itemstack, world, i, j, k)) { if (!world.isStatic) { world.triggerEffect(2005, i, j, k, 0); } @@ -68,12 +64,7 @@ public class ItemDye extends Item { if (world.isEmpty(i, j, k)) { int j1 = Blocks.COCOA.getPlacedData(world, i, j, k, l, f, f1, f2, 0); - // CraftBukkit start - fire BlockPlaceEvent - // world.setTypeAndData(i, j, k, Blocks.COCOA, j1, 2); - if (!ItemBlock.processBlockPlace(world, entityhuman, itemstack, i, j, k, Blocks.COCOA, j1, clickedX, clickedY, clickedZ)) { - return false; - } - // CraftBukkit end + world.setTypeAndData(i, j, k, Blocks.COCOA, j1, 2); if (!entityhuman.abilities.canInstantlyBuild) { --itemstack.count; } @@ -88,12 +79,6 @@ public class ItemDye extends Item { } public static boolean a(ItemStack itemstack, World world, int i, int j, int k) { - // CraftBukkit start - add EntityHuman parameter - return a(itemstack, world, i, j, k, null); - } - - public static boolean a(ItemStack itemstack, World world, int i, int j, int k, EntityHuman entityhuman) { - // CraftBukkit end Block block = world.getType(i, j, k); if (block instanceof IBlockFragilePlantElement) { @@ -102,18 +87,7 @@ public class ItemDye extends Item { if (iblockfragileplantelement.a(world, i, j, k, world.isStatic)) { if (!world.isStatic) { if (iblockfragileplantelement.a(world, world.random, i, j, k)) { - // CraftBukkit start - Special case BlockSapling and BlockMushroom to use our methods - if (block instanceof BlockSapling) { - Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null; - ((BlockSapling) block).grow(world, i, j, k, world.random, true, player, null); - } else if (block instanceof BlockMushroom) { - Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null; - ((BlockMushroom) block).grow(world, i, j, k, world.random, true, player, null); - } else { - iblockfragileplantelement.b(world, world.random, i, j, k); - } - // CraftBukkit end - + iblockfragileplantelement.b(world, world.random, i, j, k); } --itemstack.count; |