@@ -11,13 +11,31 @@
|
||||
+
|
||||
public class DispenserRegistry {
|
||||
|
||||
private static final PrintStream a = System.out;
|
||||
@@ -74,13 +79,45 @@
|
||||
public static final PrintStream a = System.out;
|
||||
@@ -69,7 +74,7 @@
|
||||
BlockDispenser.REGISTRY.a(Items.SPLASH_POTION, new IDispenseBehavior() {
|
||||
public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) {
|
||||
return (new DispenseBehaviorProjectile() {
|
||||
- protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
|
||||
+ protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue
|
||||
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
|
||||
}
|
||||
|
||||
@@ -86,7 +91,7 @@
|
||||
BlockDispenser.REGISTRY.a(Items.LINGERING_POTION, new IDispenseBehavior() {
|
||||
public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) {
|
||||
return (new DispenseBehaviorProjectile() {
|
||||
- protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
|
||||
+ protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue
|
||||
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
|
||||
}
|
||||
|
||||
@@ -106,14 +111,46 @@
|
||||
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
|
||||
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
|
||||
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
|
||||
- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), itemstack.getData(), d0, d1, d2);
|
||||
+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), itemstack.getData(), d0, d1, d2);
|
||||
- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
|
||||
+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ World world = isourceblock.getWorld();
|
||||
@@ -48,19 +66,20 @@
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+
|
||||
+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
|
||||
+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
|
||||
|
||||
if (entity instanceof EntityLiving && itemstack.hasName()) {
|
||||
((EntityInsentient) entity).setCustomName(itemstack.getName());
|
||||
entity.setCustomName(itemstack.getName());
|
||||
}
|
||||
|
||||
ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity);
|
||||
- itemstack.cloneAndSubtract(1);
|
||||
+ // itemstack.a(1); // Handled during event processing
|
||||
+ // itemstack.cloneAndSubtract(1);// Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
});
|
||||
@@ -90,10 +127,39 @@
|
||||
@@ -123,10 +160,39 @@
|
||||
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
|
||||
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
|
||||
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
|
||||
@@ -97,12 +116,12 @@
|
||||
|
||||
isourceblock.getWorld().addEntity(entityfireworks);
|
||||
- itemstack.cloneAndSubtract(1);
|
||||
+ // itemstack.a(1); // Handled during event processing
|
||||
+ // itemstack.cloneAndSubtract(1); // Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -114,8 +180,38 @@
|
||||
@@ -147,13 +213,44 @@
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
|
||||
|
||||
@@ -134,66 +153,31 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
|
||||
+ EntitySmallFireball fireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ fireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
|
||||
+
|
||||
+ world.addEntity(entitysmallfireball);
|
||||
+ world.addEntity(fireball);
|
||||
+ // itemstack.a(1); // Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -146,10 +242,38 @@
|
||||
d3 = 0.0D;
|
||||
}
|
||||
|
||||
- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
|
||||
+ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
protected void a(ISourceBlock isourceblock) {
|
||||
isourceblock.getWorld().triggerEffect(1018, isourceblock.getBlockPosition(), 0);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.count++;
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.count++;
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
||||
+ idispensebehavior.a(isourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ // CraftBukkit end
|
||||
|
||||
world.addEntity(entityboat);
|
||||
- itemstack.cloneAndSubtract(1);
|
||||
+ // itemstack.a(1); // CraftBukkit - handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -164,9 +288,48 @@
|
||||
});
|
||||
BlockDispenser.REGISTRY.a(Items.aG, new DispenserRegistry.a(EntityBoat.EnumBoatType.OAK));
|
||||
@@ -169,9 +266,48 @@
|
||||
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ World world = isourceblock.getWorld();
|
||||
+ int x = blockposition.getX();
|
||||
+ int y = blockposition.getY();
|
||||
+ int z = blockposition.getZ();
|
||||
+ if (world.isEmpty(blockposition) || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
|
||||
+ if (world.isEmpty(blockposition) || !world.getType(blockposition).getMaterial().isBuildable()) {
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
@@ -218,9 +202,9 @@
|
||||
+
|
||||
+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (itembucket.a(isourceblock.getWorld(), blockposition)) {
|
||||
if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
|
||||
- itemstack.setItem(Items.BUCKET);
|
||||
- itemstack.count = 1;
|
||||
+ // CraftBukkit start - Handle stacked buckets
|
||||
@@ -235,7 +219,7 @@
|
||||
return itemstack;
|
||||
} else {
|
||||
return this.b.a(isourceblock, itemstack);
|
||||
@@ -197,6 +360,30 @@
|
||||
@@ -202,6 +338,30 @@
|
||||
item = Items.LAVA_BUCKET;
|
||||
}
|
||||
|
||||
@@ -266,9 +250,9 @@
|
||||
world.setAir(blockposition);
|
||||
if (--itemstack.count == 0) {
|
||||
itemstack.setItem(item);
|
||||
@@ -215,11 +402,39 @@
|
||||
@@ -220,11 +380,39 @@
|
||||
World world = isourceblock.getWorld();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
@@ -309,9 +293,9 @@
|
||||
} else if (world.getType(blockposition).getBlock() == Blocks.TNT) {
|
||||
Blocks.TNT.postBreak(world, blockposition, Blocks.TNT.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(true)));
|
||||
world.setAir(blockposition);
|
||||
@@ -247,6 +462,30 @@
|
||||
@@ -252,6 +440,30 @@
|
||||
World world = isourceblock.getWorld();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
@@ -340,10 +324,10 @@
|
||||
if (ItemDye.a(itemstack, world, blockposition)) {
|
||||
if (!world.isClientSide) {
|
||||
world.triggerEffect(2005, blockposition, 0);
|
||||
@@ -274,11 +513,40 @@
|
||||
@@ -279,11 +491,40 @@
|
||||
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
World world = isourceblock.getWorld();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
|
||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
|
||||
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
|
||||
+
|
||||
@@ -352,7 +336,7 @@
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX() + 0.5, blockposition.getY() + 0.5, blockposition.getZ() + 0.5));
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
@@ -377,9 +361,52 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
world.addEntity(entitytntprimed);
|
||||
world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
|
||||
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gj, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
- --itemstack.count;
|
||||
+ // --itemstack.count; // CraftBukkit - handled above
|
||||
return itemstack;
|
||||
}
|
||||
});
|
||||
@@ -437,12 +678,40 @@
|
||||
d3 = 0.0D;
|
||||
}
|
||||
|
||||
- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
|
||||
+ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.count++;
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.count++;
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
||||
+ idispensebehavior.a(isourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityboat.a(this.c);
|
||||
entityboat.yaw = enumdirection.opposite().l();
|
||||
world.addEntity(entityboat);
|
||||
- itemstack.cloneAndSubtract(1);
|
||||
+ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user