diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-11-20 00:01:14 -0800 |
---|---|---|
committer | Erik Broes <erikbroes@ripe.net> | 2011-11-20 00:01:33 -0800 |
commit | 345ea36c7bb3383c6e4825355d0043a646194eaa (patch) | |
tree | df116b57d92315c0a13c2fdc87d792b031c7239a /src/main/java/net/minecraft/server/ItemBlock.java | |
parent | 589f66bd1b766dc1fdd737ee885304196a2ed86a (diff) | |
download | craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.gz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.lz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.xz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.zip |
Update for 1.0.0
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemBlock.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemBlock.java | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 172e9ad6..6d8c2006 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -13,7 +13,7 @@ public class ItemBlock extends Item { public ItemBlock(int i) { super(i); this.id = i + 256; - this.b(Block.byId[i + 256].a(2)); + this.d(Block.byId[i + 256].a(2)); } public int a() { @@ -54,87 +54,84 @@ public class ItemBlock extends Item { if (itemstack.count == 0) { return false; - } else if (!entityhuman.c(i, j, k)) { + } else if (!entityhuman.d(i, j, k)) { return false; - } else { - world.getClass(); - if (j == 128 - 1 && Block.byId[this.id].material.isBuildable()) { - return false; - } else if (world.a(this.id, i, j, k, false, l)) { - Block block = Block.byId[this.id]; - - // CraftBukkit start - This executes the placement of the block - CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); - - // There are like 30 combinations you can mix and match steps and double steps - // of different materials, so there are a lot of different cases of what - // would happen if you place x step onto another y step, so let's just keep - // track of the entire state - CraftBlockState blockStateBelow = null; - // Toggles whether the normal or the block below is used for the place event - boolean eventUseBlockBelow = false; - if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) - && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { - blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); - // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block - eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; - } + } else if (j == world.height - 1 && Block.byId[this.id].material.isBuildable()) { + return false; + } else if (world.a(this.id, i, j, k, false, l)) { + Block block = Block.byId[this.id]; + + // CraftBukkit start - This executes the placement of the block + CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); + + // There are like 30 combinations you can mix and match steps and double steps + // of different materials, so there are a lot of different cases of what + // would happen if you place x step onto another y step, so let's just keep + // track of the entire state + CraftBlockState blockStateBelow = null; + // Toggles whether the normal or the block below is used for the place event + boolean eventUseBlockBelow = false; + if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) + && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { + blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); + // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block + eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; + } - /** - * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) - * - * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to - * hook between the 'placement' and the informing to 'world' so we can - * sanely undo this. - * - * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to - * replace this with. - */ - if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); - - if (event.isCancelled() || !event.canBuild()) { - if (blockStateBelow != null) { // Used for steps - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); - world.setTypeIdAndData(i, j - 1, k, blockStateBelow.getTypeId(), blockStateBelow.getRawData()); - - } else { - - if (this.id == Block.ICE.id) { - // Ice will explode if we set straight to 0 - world.setTypeId(i, j, k, 20); - } - - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); + /** + * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) + * + * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to + * hook between the 'placement' and the informing to 'world' so we can + * sanely undo this. + * + * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to + * replace this with. + */ + if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); + + if (event.isCancelled() || !event.canBuild()) { + if (blockStateBelow != null) { // Used for steps + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); + world.setTypeIdAndData(i, j - 1, k, blockStateBelow.getTypeId(), blockStateBelow.getRawData()); + + } else { + + if (this.id == Block.ICE.id) { + // Ice will explode if we set straight to 0 + world.setTypeId(i, j, k, 20); } - return true; + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); } - world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) + return true; - // CraftBukkit end + } + world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) - if (world.getTypeId(i, j, k) == this.id) { - Block.byId[this.id].postPlace(world, i, j, k, l); - Block.byId[this.id].postPlace(world, i, j, k, entityhuman); - } + // CraftBukkit end - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); - --itemstack.count; + if (world.getTypeId(i, j, k) == this.id) { + Block.byId[this.id].postPlace(world, i, j, k, l); + Block.byId[this.id].postPlace(world, i, j, k, entityhuman); } - return true; - } else { - return false; + world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); + --itemstack.count; } + + return true; + } else { + return false; } } public String a(ItemStack itemstack) { - return Block.byId[this.id].l(); + return Block.byId[this.id].n(); } public String b() { - return Block.byId[this.id].l(); + return Block.byId[this.id].n(); } } |