diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2013-03-16 16:35:30 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2013-03-16 16:48:08 -0500 |
commit | fbe609bdbe11d480cba162385926c2f0a36c8a49 (patch) | |
tree | 172a26a2c182899ec3dabcc612c5c90ca05e45d5 /src | |
parent | ff1c1daf692ab0efacba81e77cd26d5ccdecd20c (diff) | |
download | craftbukkit-fbe609bdbe11d480cba162385926c2f0a36c8a49.tar craftbukkit-fbe609bdbe11d480cba162385926c2f0a36c8a49.tar.gz craftbukkit-fbe609bdbe11d480cba162385926c2f0a36c8a49.tar.lz craftbukkit-fbe609bdbe11d480cba162385926c2f0a36c8a49.tar.xz craftbukkit-fbe609bdbe11d480cba162385926c2f0a36c8a49.zip |
Add new DispenseBehavior files from mc-dev for diff visibility.
Diffstat (limited to 'src')
4 files changed, 127 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java b/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java new file mode 100644 index 00000000..06e77b62 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java @@ -0,0 +1,32 @@ +package net.minecraft.server; + +import java.util.List; + +final class DispenseBehaviorArmor extends DispenseBehaviorItem { + + DispenseBehaviorArmor() {} + + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h()); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY() + enumfacing.d(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1)); + List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack))); + + if (list.size() > 0) { + EntityLiving entityliving = (EntityLiving) list.get(0); + int l = entityliving instanceof EntityHuman ? 1 : 0; + int i1 = EntityLiving.b(itemstack); + ItemStack itemstack1 = itemstack.cloneItemStack(); + + itemstack1.count = 1; + entityliving.setEquipment(i1 - l, itemstack1); + entityliving.a(i1, 2.0F); + --itemstack.count; + return itemstack; + } else { + return super.b(isourceblock, itemstack); + } + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java b/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java new file mode 100644 index 00000000..4f182171 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java @@ -0,0 +1,38 @@ +package net.minecraft.server; + +final class DispenseBehaviorBonemeal extends DispenseBehaviorItem { + + private boolean b = true; + + DispenseBehaviorBonemeal() {} + + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + if (itemstack.getData() == 15) { + EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h()); + World world = isourceblock.k(); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY() + enumfacing.d(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + + if (ItemDye.a(itemstack, world, i, j, k)) { + if (!world.isStatic) { + world.triggerEffect(2005, i, j, k, 0); + } + } else { + this.b = false; + } + + return itemstack; + } else { + return super.b(isourceblock, itemstack); + } + } + + protected void a(ISourceBlock isourceblock) { + if (this.b) { + isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } else { + isourceblock.k().triggerEffect(1001, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java b/src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java new file mode 100644 index 00000000..b143f619 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java @@ -0,0 +1,38 @@ +package net.minecraft.server; + +final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem { + + private boolean b = true; + + DispenseBehaviorFlintAndSteel() {} + + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h()); + World world = isourceblock.k(); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY() + enumfacing.d(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + + if (world.isEmpty(i, j, k)) { + world.setTypeIdUpdate(i, j, k, Block.FIRE.id); + if (itemstack.isDamaged(1, world.random)) { + itemstack.count = 0; + } + } else if (world.getTypeId(i, j, k) == Block.TNT.id) { + Block.TNT.postBreak(world, i, j, k, 1); + world.setAir(i, j, k); + } else { + this.b = false; + } + + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + if (this.b) { + isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } else { + isourceblock.k().triggerEffect(1001, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java b/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java new file mode 100644 index 00000000..724a2eef --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java @@ -0,0 +1,19 @@ +package net.minecraft.server; + +final class DispenseBehaviorTNT extends DispenseBehaviorItem { + + DispenseBehaviorTNT() {} + + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h()); + World world = isourceblock.k(); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY() + enumfacing.d(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), (EntityLiving) null); + + world.addEntity(entitytntprimed); + --itemstack.count; + return itemstack; + } +} |