geforkt von Mirrors/Paper
Fire BlockDispenseEvent for new dispenser behaviors. Fixes BUKKIT-3774
Dieser Commit ist enthalten in:
Ursprung
fbe609bdbe
Commit
0e60f1f7b8
@ -2,6 +2,11 @@ package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
final class DispenseBehaviorArmor extends DispenseBehaviorItem {
|
||||
|
||||
DispenseBehaviorArmor() {}
|
||||
@ -18,12 +23,39 @@ final class DispenseBehaviorArmor extends DispenseBehaviorItem {
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
int l = entityliving instanceof EntityHuman ? 1 : 0;
|
||||
int i1 = EntityLiving.b(itemstack);
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
// CraftBukkit start
|
||||
ItemStack itemstack1 = itemstack.a(1);
|
||||
World world = isourceblock.k();
|
||||
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
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()) {
|
||||
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.a.a(eventStack.getItem());
|
||||
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
|
||||
idispensebehavior.a(isourceblock, eventStack);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
itemstack1.count = 1;
|
||||
entityliving.setEquipment(i1 - l, itemstack1);
|
||||
entityliving.a(i1, 2.0F);
|
||||
--itemstack.count;
|
||||
// --itemstack.count; // CraftBukkit - handled above
|
||||
return itemstack;
|
||||
} else {
|
||||
return super.b(isourceblock, itemstack);
|
||||
|
@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
final class DispenseBehaviorBonemeal extends DispenseBehaviorItem {
|
||||
|
||||
private boolean b = true;
|
||||
@ -14,7 +19,34 @@ final class DispenseBehaviorBonemeal extends DispenseBehaviorItem {
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
|
||||
if (ItemDye.a(itemstack, world, i, j, k)) {
|
||||
// CraftBukkit start
|
||||
ItemStack itemstack1 = itemstack.a(1);
|
||||
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
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()) {
|
||||
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.a.a(eventStack.getItem());
|
||||
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
|
||||
idispensebehavior.a(isourceblock, eventStack);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (ItemDye.a(itemstack1, world, i, j, k)) { // CraftBukkit - itemstack -> itemstack1
|
||||
if (!world.isStatic) {
|
||||
world.triggerEffect(2005, i, j, k, 0);
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem {
|
||||
|
||||
private boolean b = true;
|
||||
@ -13,6 +18,30 @@ final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem {
|
||||
int j = isourceblock.getBlockY() + enumfacing.d();
|
||||
int k = isourceblock.getBlockZ() + enumfacing.e();
|
||||
|
||||
// CraftBukkit start
|
||||
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
|
||||
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());
|
||||
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
|
||||
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
|
||||
idispensebehavior.a(isourceblock, eventStack);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if (world.isEmpty(i, j, k)) {
|
||||
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
||||
if (itemstack.isDamaged(1, world.random)) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
final class DispenseBehaviorTNT extends DispenseBehaviorItem {
|
||||
|
||||
DispenseBehaviorTNT() {}
|
||||
@ -10,10 +15,38 @@ final class DispenseBehaviorTNT extends DispenseBehaviorItem {
|
||||
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);
|
||||
|
||||
// CraftBukkit start
|
||||
ItemStack itemstack1 = itemstack.a(1);
|
||||
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(i + 0.5, j + 0.5, k + 0.5));
|
||||
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.a.a(eventStack.getItem());
|
||||
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
|
||||
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);
|
||||
--itemstack.count;
|
||||
// --itemstack.count; // CraftBukkit - handled above
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren