mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
re-add a dispense fix patch
This commit is contained in:
parent
a4c7496404
commit
dbdce60ac9
1 changed files with 109 additions and 133 deletions
|
@ -13,8 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java
|
||||
@@ -0,0 +0,0 @@ public class BoatDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
}
|
||||
|
||||
// Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3);
|
||||
// CraftBukkit start
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink at end and single item in event
|
||||
|
@ -36,17 +36,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public class BoatDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
EntityType.createDefaultStackConfig(worldserver, stack, (Player) null).accept(object);
|
||||
((Boat) object).setVariant(this.type);
|
||||
((Boat) object).setYRot(enumdirection.toYRot());
|
||||
- if (!worldserver.addFreshEntity((Entity) object)) stack.grow(1); // CraftBukkit
|
||||
- // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ if (worldserver.addFreshEntity((Entity) object) && shrink) stack.shrink(1); // Paper - if entity add was successful and supposed to shrink
|
||||
return stack;
|
||||
}
|
||||
abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit
|
||||
EntityType.createDefaultStackConfig(worldserver, stack, (Player) null).accept(abstractboat);
|
||||
abstractboat.setYRot(enumdirection.toYRot());
|
||||
- if (!worldserver.addFreshEntity(abstractboat)) stack.grow(1); // CraftBukkit
|
||||
- // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ if (worldserver.addFreshEntity(abstractboat) && shrink) stack.shrink(1); // Paper - if entity add was successful and supposed to shrink
|
||||
}
|
||||
|
||||
return stack;
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
|
@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.spawn(worldserver, consumer, blockposition, MobSpawnType.DISPENSER, false, false);
|
||||
ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false);
|
||||
|
||||
if (entityarmorstand != null) {
|
||||
- // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
|
@ -143,48 +143,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
}
|
||||
((Saddleable) list.get(0)).equipSaddle(itemstack1, SoundSource.BLOCKS);
|
||||
((Saddleable) list.get(0)).equipSaddle(CraftItemStack.asNMSCopy(event.getItem()), SoundSource.BLOCKS); // Paper - track changed items in dispense event
|
||||
// CraftBukkit end
|
||||
+ if (shrink) stack.shrink(1); // Paper - actually handle here
|
||||
this.setSuccess(true);
|
||||
return stack;
|
||||
} else {
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
} while (!entityhorseabstract.isBodyArmorItem(stack) || entityhorseabstract.isWearingBodyArmor() || !entityhorseabstract.isTamed());
|
||||
|
||||
// CraftBukkit start
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
ServerLevel world = pointer.level();
|
||||
org.bukkit.block.Block block = CraftBlock.at(world, pointer.pos());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
- stack.grow(1);
|
||||
+ // stack.grow(1); // Paper - shrink below
|
||||
return stack;
|
||||
}
|
||||
|
||||
+ boolean shrink = true; // Paper
|
||||
if (!event.getItem().equals(craftItem)) {
|
||||
- stack.grow(1);
|
||||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (shrink) stack.shrink(1); // Paper - shrink here
|
||||
entityhorseabstract.setBodyArmorItem(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
// CraftBukkit end
|
||||
this.setSuccess(true);
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
entityhorsechestedabstract = (AbstractChestedHorse) iterator1.next();
|
||||
// CraftBukkit start
|
||||
|
@ -207,7 +174,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
entityhorsechestedabstract.getSlot(499).set(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
// CraftBukkit end
|
||||
|
@ -277,7 +244,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
worldserver.addFreshEntity(entitytntprimed);
|
||||
worldserver.playSound((Player) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
|
@ -314,6 +281,91 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
if (!DispenserBlock.eventFired) {
|
||||
@@ -0,0 +0,0 @@ public interface DispenseItemBehavior {
|
||||
ItemStack itemstack1 = stack;
|
||||
ServerLevel world = pointer.level();
|
||||
org.bukkit.block.Block block = CraftBlock.at(world, pointer.pos());
|
||||
- CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); // Paper - ignore stack size on damageable items
|
||||
|
||||
BlockDispenseEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity());
|
||||
if (!DispenserBlock.eventFired) {
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
@@ -0,0 +0,0 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
} else {
|
||||
LivingEntity entityliving = (LivingEntity) list.getFirst();
|
||||
EquipmentSlot enumitemslot = entityliving.getEquipmentSlotForItem(stack);
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
|
||||
// CraftBukkit start
|
||||
Level world = pointer.level();
|
||||
@@ -0,0 +0,0 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
- stack.grow(1);
|
||||
+ // stack.grow(1); // Paper - shrink below
|
||||
return false;
|
||||
}
|
||||
|
||||
+ boolean shrink = true; // Paper
|
||||
if (!event.getItem().equals(craftItem)) {
|
||||
- stack.grow(1);
|
||||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
entityinsentient.setPersistenceRequired();
|
||||
}
|
||||
|
||||
+ if (shrink) stack.shrink(1); // Paper - shrink here
|
||||
return true;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
@@ -0,0 +0,0 @@ public class MinecartDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
Vec3 vec3d1 = new Vec3(d0, d1 + d3, d2);
|
||||
// CraftBukkit start
|
||||
// EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null);
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
org.bukkit.block.Block block2 = CraftBlock.at(worldserver, pointer.pos());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class MinecartDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
- stack.grow(1);
|
||||
+ // stack.grow(1); // Paper - shrink below
|
||||
return stack;
|
||||
}
|
||||
|
||||
+ boolean shrink = true; // Paper
|
||||
if (!event.getItem().equals(craftItem)) {
|
||||
- stack.grow(1);
|
||||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public class MinecartDispenseItemBehavior extends DefaultDispenseItemBehavior {
|
||||
AbstractMinecart entityminecartabstract = AbstractMinecart.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.entityType, EntitySpawnReason.DISPENSER, itemstack1, (Player) null);
|
||||
|
||||
if (entityminecartabstract != null) {
|
||||
- if (!worldserver.addFreshEntity(entityminecartabstract)) stack.grow(1);
|
||||
- // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ if (worldserver.addFreshEntity(entityminecartabstract) && shrink) stack.shrink(1); // Paper - if entity add was successful and supposed to shrink
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java
|
||||
|
@ -321,9 +373,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
@@ -0,0 +0,0 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior {
|
||||
|
||||
// CraftBukkit start
|
||||
// this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
// IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // CraftBukkit - call when finish the BlockDispenseEvent
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
org.bukkit.block.Block block = CraftBlock.at(worldserver, pointer.pos());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
|
@ -342,16 +394,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(pointer, eventStack); // Paper - Fix NPE with equippable and items without behavior
|
||||
@@ -0,0 +0,0 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior {
|
||||
((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity());
|
||||
// CraftBukkit end
|
||||
worldserver.addFreshEntity(iprojectile);
|
||||
Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, CraftItemStack.unwrap(event.getItem()), enumdirection), worldserver, itemstack1, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // Paper - track changed items in the dispense event; unwrap is safe here because all uses of the stack make their own copies
|
||||
iprojectile.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(pointer.blockEntity());
|
||||
}
|
||||
- // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
+ if (shrink) stack.shrink(1); // Paper - actually handle here
|
||||
// CraftBukkit end
|
||||
return stack;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
|
||||
|
@ -378,79 +430,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
if (!DispenserBlock.eventFired) {
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ArmorItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ArmorItem.java
|
||||
@@ -0,0 +0,0 @@ public class ArmorItem extends Item implements Equipable {
|
||||
} else {
|
||||
LivingEntity entityliving = (LivingEntity) list.get(0);
|
||||
EquipmentSlot enumitemslot = entityliving.getEquipmentSlotForItem(armor);
|
||||
- ItemStack itemstack1 = armor.split(1);
|
||||
+ ItemStack itemstack1 = armor.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
// CraftBukkit start
|
||||
Level world = pointer.level();
|
||||
org.bukkit.block.Block block = CraftBlock.at(world, pointer.pos());
|
||||
@@ -0,0 +0,0 @@ public class ArmorItem extends Item implements Equipable {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
- armor.grow(1);
|
||||
+ // armor.grow(1); // Paper - shrink below
|
||||
return false;
|
||||
}
|
||||
|
||||
+ boolean shrink = true; // Paper
|
||||
if (!event.getItem().equals(craftItem)) {
|
||||
- armor.grow(1);
|
||||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@@ -0,0 +0,0 @@ public class ArmorItem extends Item implements Equipable {
|
||||
((Mob) entityliving).setPersistenceRequired();
|
||||
}
|
||||
|
||||
+ if (shrink) armor.shrink(1); // Paper
|
||||
return true;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MinecartItem.java b/src/main/java/net/minecraft/world/item/MinecartItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MinecartItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MinecartItem.java
|
||||
@@ -0,0 +0,0 @@ public class MinecartItem extends Item {
|
||||
|
||||
// CraftBukkit start
|
||||
// EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type);
|
||||
- ItemStack itemstack1 = stack.split(1);
|
||||
+ ItemStack itemstack1 = stack.copyWithCount(1); // Paper - shrink below and single item in event
|
||||
org.bukkit.block.Block block2 = CraftBlock.at(worldserver, pointer.pos());
|
||||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class MinecartItem extends Item {
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
- stack.grow(1);
|
||||
+ // stack.grow(1); // Paper - shrink below
|
||||
return stack;
|
||||
}
|
||||
|
||||
+ boolean shrink = true; // Paper
|
||||
if (!event.getItem().equals(craftItem)) {
|
||||
- stack.grow(1);
|
||||
+ shrink = false; // Paper - shrink below
|
||||
// Chain to handler for new item
|
||||
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@@ -0,0 +0,0 @@ public class MinecartItem extends Item {
|
||||
itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
AbstractMinecart entityminecartabstract = AbstractMinecart.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((MinecartItem) itemstack1.getItem()).type, itemstack1, (Player) null);
|
||||
|
||||
- if (!worldserver.addFreshEntity(entityminecartabstract)) stack.grow(1);
|
||||
- // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ if (worldserver.addFreshEntity(entityminecartabstract) && shrink) stack.shrink(1); // Paper - actually handle here
|
||||
// CraftBukkit end
|
||||
return stack;
|
||||
}
|
Loading…
Reference in a new issue