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 0000000000..06e77b62a1 --- /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 0000000000..4f18217138 --- /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 0000000000..b143f6198c --- /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 0000000000..724a2eef47 --- /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; + } +}