13
0
geforkt von Mirrors/Paper

SPIGOT-7536: Using Crafter crashes server

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2023-12-07 19:49:43 +11:00
Ursprung 07a9ff30de
Commit 628e3adf0e

Datei anzeigen

@ -24,7 +24,7 @@
public DispenseBehaviorItem() {} public DispenseBehaviorItem() {}
@Override @Override
@@ -25,11 +40,19 @@ @@ -25,11 +40,22 @@
IPosition iposition = BlockDispenser.getDispensePosition(sourceblock); IPosition iposition = BlockDispenser.getDispensePosition(sourceblock);
ItemStack itemstack1 = itemstack.split(1); ItemStack itemstack1 = itemstack.split(1);
@ -37,21 +37,31 @@
return itemstack; return itemstack;
} }
- public static void spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) { public static void spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument, dropper + // CraftBukkit start
+ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, SourceBlock sourceblock, boolean dropper) { + EntityItem entityitem = prepareItem(world, itemstack, i, enumdirection, iposition);
+ if (itemstack.isEmpty()) return true; + world.addFreshEntity(entityitem);
+ IPosition iposition = BlockDispenser.getDispensePosition(sourceblock); + }
+
+ private static EntityItem prepareItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
+ // CraftBukkit end + // CraftBukkit end
double d0 = iposition.x(); double d0 = iposition.x();
double d1 = iposition.y(); double d1 = iposition.y();
double d2 = iposition.z(); double d2 = iposition.z();
@@ -44,7 +67,39 @@ @@ -44,7 +70,47 @@
double d3 = world.random.nextDouble() * 0.1D + 0.2D; double d3 = world.random.nextDouble() * 0.1D + 0.2D;
entityitem.setDeltaMovement(world.random.triangle((double) enumdirection.getStepX() * d3, 0.0172275D * (double) i), world.random.triangle(0.2D, 0.0172275D * (double) i), world.random.triangle((double) enumdirection.getStepZ() * d3, 0.0172275D * (double) i)); entityitem.setDeltaMovement(world.random.triangle((double) enumdirection.getStepX() * d3, 0.0172275D * (double) i), world.random.triangle(0.2D, 0.0172275D * (double) i), world.random.triangle((double) enumdirection.getStepZ() * d3, 0.0172275D * (double) i));
+
+ // CraftBukkit start + // CraftBukkit start
+ return entityitem;
+ }
+
+ // CraftBukkit - void -> boolean return, IPosition -> ISourceBlock last argument, dropper
+ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, SourceBlock sourceblock, boolean dropper) {
+ if (itemstack.isEmpty()) return true;
+ IPosition iposition = BlockDispenser.getDispensePosition(sourceblock);
+ EntityItem entityitem = prepareItem(world, itemstack, i, enumdirection, iposition);
+
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); + org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +