2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/DispenserRegistry.java
|
|
|
|
+++ b/net/minecraft/server/DispenserRegistry.java
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -7,6 +7,11 @@
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
+import org.bukkit.event.block.BlockDispenseEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class DispenserRegistry {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
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 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
|
|
|
|
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
|
|
|
|
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
|
2016-02-29 22:32:46 +01:00
|
|
|
- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
|
|
|
|
+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
2015-07-30 08:56:52 +02:00
|
|
|
+ World world = isourceblock.getWorld();
|
|
|
|
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ 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, 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());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
|
|
|
if (entity instanceof EntityLiving && itemstack.hasName()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
entity.setCustomName(itemstack.getName());
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity);
|
2015-07-30 08:56:52 +02:00
|
|
|
- itemstack.cloneAndSubtract(1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // itemstack.cloneAndSubtract(1);// Handled during event processing
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
});
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -123,10 +160,39 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
|
|
|
|
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
|
|
|
|
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
|
2015-07-30 08:56:52 +02:00
|
|
|
- EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), d0, d1, d2, itemstack);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit start
|
2015-07-30 08:56:52 +02:00
|
|
|
+ World world = isourceblock.getWorld();
|
|
|
|
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ 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, 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());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2015-06-14 05:50:04 +02:00
|
|
|
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2015-07-30 08:56:52 +02:00
|
|
|
isourceblock.getWorld().addEntity(entityfireworks);
|
|
|
|
- itemstack.cloneAndSubtract(1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // itemstack.cloneAndSubtract(1); // Handled during event processing
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -147,8 +213,38 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
|
|
|
|
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
|
|
|
|
|
|
|
|
- world.addEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
|
2015-07-30 08:56:52 +02:00
|
|
|
- itemstack.cloneAndSubtract(1);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit start
|
2015-07-30 08:56:52 +02:00
|
|
|
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ 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(d3, d4, d5));
|
|
|
|
+ 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());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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());
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ world.addEntity(fireball);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // itemstack.a(1); // Handled during event processing
|
|
|
|
+ // CraftBukkit end
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -169,9 +265,48 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
|
2016-06-09 03:43:49 +02:00
|
|
|
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
|
2015-02-26 23:41:06 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
2015-07-30 08:56:52 +02:00
|
|
|
+ World world = isourceblock.getWorld();
|
2015-02-26 23:41:06 +01:00
|
|
|
+ int x = blockposition.getX();
|
|
|
|
+ int y = blockposition.getY();
|
|
|
|
+ int z = blockposition.getZ();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (world.isEmpty(blockposition) || !world.getType(blockposition).getMaterial().isBuildable()) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
|
|
|
+
|
|
|
|
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
|
|
|
|
+ if (!BlockDispenser.eventFired) {
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
|
|
+ // Chain to handler for new item
|
|
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
|
2015-02-26 23:41:06 +01:00
|
|
|
- itemstack.setItem(Items.BUCKET);
|
|
|
|
- itemstack.count = 1;
|
|
|
|
+ // CraftBukkit start - Handle stacked buckets
|
|
|
|
+ Item item = Items.BUCKET;
|
|
|
|
+ if (--itemstack.count == 0) {
|
|
|
|
+ itemstack.setItem(Items.BUCKET);
|
|
|
|
+ itemstack.count = 1;
|
|
|
|
+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
|
|
|
|
+ this.b.a(isourceblock, new ItemStack(item));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
|
|
|
return this.b.a(isourceblock, itemstack);
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -202,6 +337,30 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
item = Items.LAVA_BUCKET;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
|
|
|
+
|
|
|
|
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
|
|
+ if (!BlockDispenser.eventFired) {
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
|
|
+ // Chain to handler for new item
|
|
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
world.setAir(blockposition);
|
|
|
|
if (--itemstack.count == 0) {
|
|
|
|
itemstack.setItem(item);
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -220,11 +379,39 @@
|
2015-07-30 08:56:52 +02:00
|
|
|
World world = isourceblock.getWorld();
|
2016-06-09 03:43:49 +02:00
|
|
|
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
|
2015-02-26 23:41:06 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
|
|
|
+
|
|
|
|
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
|
|
|
+ if (!BlockDispenser.eventFired) {
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
|
|
+ // Chain to handler for new item
|
|
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
if (world.isEmpty(blockposition)) {
|
|
|
|
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
- if (itemstack.isDamaged(1, world.random)) {
|
|
|
|
- itemstack.count = 0;
|
|
|
|
+ // CraftBukkit start - Ignition by dispensing flint and steel
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()).isCancelled()) {
|
|
|
|
+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ if (itemstack.isDamaged(1, world.random)) {
|
|
|
|
+ itemstack.count = 0;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end
|
|
|
|
} 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);
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -252,6 +439,30 @@
|
2015-07-30 08:56:52 +02:00
|
|
|
World world = isourceblock.getWorld();
|
2016-06-09 03:43:49 +02:00
|
|
|
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
|
2015-02-26 23:41:06 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asNewCraftStack(itemstack.getItem());
|
|
|
|
+
|
|
|
|
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
|
|
|
+ if (!BlockDispenser.eventFired) {
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!event.getItem().equals(craftItem)) {
|
|
|
|
+ // Chain to handler for new item
|
|
|
|
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
if (ItemDye.a(itemstack, world, blockposition)) {
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
world.triggerEffect(2005, blockposition, 0);
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -279,11 +490,40 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
|
2015-07-30 08:56:52 +02:00
|
|
|
World world = isourceblock.getWorld();
|
2016-06-09 03:43:49 +02:00
|
|
|
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
|
2015-02-26 23:41:06 +01:00
|
|
|
- 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);
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
2015-07-30 08:56:52 +02:00
|
|
|
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
|
|
|
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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));
|
2015-02-26 23:41:06 +01:00
|
|
|
+ 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());
|
2015-07-30 08:56:52 +02:00
|
|
|
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
|
|
|
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ idispensebehavior.a(isourceblock, eventStack);
|
|
|
|
+ return itemstack;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
world.addEntity(entitytntprimed);
|
2016-08-20 01:48:07 +02:00
|
|
|
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gz, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
2015-02-26 23:41:06 +01:00
|
|
|
- --itemstack.count;
|
|
|
|
+ // --itemstack.count; // CraftBukkit - handled above
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
});
|
2016-03-30 21:50:59 +02:00
|
|
|
@@ -437,12 +677,40 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
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
|
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
entityboat.setType(this.c);
|
2016-02-29 22:32:46 +01:00
|
|
|
entityboat.yaw = enumdirection.opposite().l();
|
|
|
|
world.addEntity(entityboat);
|
|
|
|
- itemstack.cloneAndSubtract(1);
|
|
|
|
+ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|