@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
+++ b/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
@@ -34,9 +34,15 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@@ -36,14 +36,20 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||
@@ -11,27 +11,28 @@
|
||||
public interface CauldronInteraction {
|
||||
|
||||
Map<String, CauldronInteraction.a> INTERACTIONS = new Object2ObjectArrayMap();
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ /*
|
||||
Codec<CauldronInteraction.a> CODEC;
|
||||
CauldronInteraction.a EMPTY;
|
||||
CauldronInteraction.a WATER;
|
||||
@@ -48,6 +54,8 @@
|
||||
CauldronInteraction SHULKER_BOX;
|
||||
CauldronInteraction BANNER;
|
||||
CauldronInteraction DYED_ITEM;
|
||||
+ */
|
||||
- Codec<CauldronInteraction.a> CODEC;
|
||||
- CauldronInteraction.a EMPTY;
|
||||
- CauldronInteraction.a WATER;
|
||||
- CauldronInteraction.a LAVA;
|
||||
- CauldronInteraction.a POWDER_SNOW;
|
||||
+ // CraftBukkit start - decompile errors
|
||||
+ Codec<CauldronInteraction.a> CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get);
|
||||
+ CauldronInteraction.a EMPTY = newInteractionMap("empty");
|
||||
+ CauldronInteraction.a WATER = newInteractionMap("water");
|
||||
+ CauldronInteraction.a LAVA = newInteractionMap("lava");
|
||||
+ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
+ // CraftBukkit end
|
||||
|
||||
static CauldronInteraction.a newInteractionMap(String s) {
|
||||
Object2ObjectOpenHashMap<Item, CauldronInteraction> object2objectopenhashmap = new Object2ObjectOpenHashMap();
|
||||
@@ -72,12 +80,17 @@
|
||||
@@ -68,12 +74,17 @@
|
||||
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@@ -44,13 +45,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -97,12 +110,17 @@
|
||||
@@ -93,12 +104,17 @@
|
||||
});
|
||||
map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@@ -63,13 +64,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -117,10 +135,15 @@
|
||||
@@ -113,10 +129,15 @@
|
||||
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
@@ -80,13 +81,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -198,12 +221,17 @@
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
@@ -194,12 +215,17 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@@ -99,13 +100,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -214,12 +242,17 @@
|
||||
@@ -210,12 +236,17 @@
|
||||
|
||||
static ItemInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
|
||||
static EnumInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@@ -118,113 +119,74 @@
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -227,76 +260,89 @@
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -242,11 +273,16 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1);
|
||||
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -260,12 +296,17 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.copyWithCount(1);
|
||||
|
||||
itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast());
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -279,9 +320,14 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
itemstack.remove(DataComponents.DYED_COLOR);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_ARMOR);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -294,6 +340,8 @@
|
||||
return fluid.is(TagsFluid.WATER);
|
||||
}
|
||||
|
||||
- static {
|
||||
- Function function = CauldronInteraction.a::name;
|
||||
- Map map = CauldronInteraction.INTERACTIONS;
|
||||
-
|
||||
- Objects.requireNonNull(map);
|
||||
- CODEC = Codec.stringResolver(function, map::get);
|
||||
- EMPTY = newInteractionMap("empty");
|
||||
- WATER = newInteractionMap("water");
|
||||
- LAVA = newInteractionMap("lava");
|
||||
- POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
- FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ // CraftBukkit start - decompile errors
|
||||
+ // static {
|
||||
+ Codec<CauldronInteraction.a> CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get);
|
||||
+ CauldronInteraction.a EMPTY = newInteractionMap("empty");
|
||||
+ CauldronInteraction.a WATER = newInteractionMap("water");
|
||||
+ CauldronInteraction.a LAVA = newInteractionMap("lava");
|
||||
+ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
+ CauldronInteraction FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY);
|
||||
};
|
||||
- FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEffects.BUCKET_EMPTY_LAVA);
|
||||
};
|
||||
- FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY_POWDER_SNOW);
|
||||
};
|
||||
- SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ // CraftBukkit end
|
||||
Block block = Block.byItem(itemstack.getItem());
|
||||
|
||||
if (!(block instanceof BlockShulkerBox)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1);
|
||||
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error
|
||||
BannerPatternLayers bannerpatternlayers = (BannerPatternLayers) itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY);
|
||||
|
||||
if (bannerpatternlayers.layers().isEmpty()) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.copyWithCount(1);
|
||||
|
||||
itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast());
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error
|
||||
if (!itemstack.is(TagsItem.DYEABLE)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else if (!itemstack.has(DataComponents.DYED_COLOR)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
itemstack.remove(DataComponents.DYED_COLOR);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_ARMOR);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- }
|
||||
+ // } // CraftBukkit - decompile error
|
||||
+ /*
|
||||
static {
|
||||
Function function = CauldronInteraction.a::name;
|
||||
Map map = CauldronInteraction.INTERACTIONS;
|
||||
@@ -305,6 +353,8 @@
|
||||
LAVA = newInteractionMap("lava");
|
||||
POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static record a(String name, Map<Item, CauldronInteraction> map) {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
|
||||
+++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
|
||||
@@ -13,6 +13,12 @@
|
||||
@@ -12,6 +12,12 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -12,13 +12,11 @@
|
||||
+
|
||||
public class DispenseBehaviorBoat extends DispenseBehaviorItem {
|
||||
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior;
|
||||
@@ -51,13 +57,41 @@
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
|
||||
@@ -43,14 +49,40 @@
|
||||
d4 = 0.0D;
|
||||
}
|
||||
|
||||
- Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3);
|
||||
+ // Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
@@ -44,17 +42,18 @@
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ EntityBoat object = this.isChestBoat ? new ChestBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()) : new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ // CraftBukkit end
|
||||
AbstractBoat abstractboat = (AbstractBoat) this.type.create(worldserver, EntitySpawnReason.DISPENSER);
|
||||
|
||||
if (abstractboat != null) {
|
||||
- abstractboat.setInitialPos(d1, d2 + d4, d3);
|
||||
+ abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(abstractboat);
|
||||
abstractboat.setYRot(enumdirection.toYRot());
|
||||
- worldserver.addFreshEntity(abstractboat);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity(abstractboat)) itemstack.grow(1); // CraftBukkit
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
}
|
||||
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(object);
|
||||
((EntityBoat) object).setVariant(this.type);
|
||||
((EntityBoat) object).setYRot(enumdirection.toYRot());
|
||||
- worldserver.addFreshEntity((Entity) object);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity((Entity) object)) itemstack.grow(1); // CraftBukkit
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
public class DispenseBehaviorProjectile extends DispenseBehaviorItem {
|
||||
|
||||
private final ProjectileItem projectileItem;
|
||||
@@ -32,9 +39,38 @@
|
||||
@@ -31,8 +38,37 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
IPosition iposition = this.dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection);
|
||||
IProjectile iprojectile = this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection);
|
||||
|
||||
- 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());
|
||||
- itemstack.shrink(1);
|
||||
+ // CraftBukkit start
|
||||
+ // this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
@@ -46,12 +47,10 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.projectileItem.shoot(iprojectile, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ IProjectile iprojectile = IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
|
||||
+ // CraftBukkit end
|
||||
worldserver.addFreshEntity(iprojectile);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
if (!worldserver.isClientSide()) {
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
|
||||
- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition));
|
||||
+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit
|
||||
- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack));
|
||||
+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack, bukkitBlock, craftItem)); // CraftBukkit
|
||||
if (this.isSuccess()) {
|
||||
itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> {
|
||||
});
|
||||
@@ -54,8 +54,8 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition) {
|
||||
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
|
||||
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
|
||||
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
@@ -68,6 +68,6 @@
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ishearable.shear(SoundCategory.BLOCKS);
|
||||
ishearable.shear(worldserver, SoundCategory.BLOCKS, itemstack);
|
||||
worldserver.gameEvent((Entity) null, (Holder) GameEvent.SHEAR, blockposition);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
@@ -10,6 +10,13 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.level.World;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EquipmentDispenseItemBehavior extends DispenseBehaviorItem {
|
||||
|
||||
public static final EquipmentDispenseItemBehavior INSTANCE = new EquipmentDispenseItemBehavior();
|
||||
@@ -34,7 +41,34 @@
|
||||
EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
|
||||
- entityliving.setItemSlot(enumitemslot, itemstack1);
|
||||
+ // CraftBukkit start
|
||||
+ World world = sourceblock.level();
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
if (entityliving instanceof EntityInsentient) {
|
||||
EntityInsentient entityinsentient = (EntityInsentient) entityliving;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
@@ -67,6 +67,22 @@
|
||||
@@ -63,6 +63,22 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
public interface IDispenseBehavior {
|
||||
|
||||
Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -94,14 +110,42 @@
|
||||
@@ -90,14 +106,42 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack);
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
+ }
|
||||
+
|
||||
try {
|
||||
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
|
||||
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false);
|
||||
} catch (Exception exception) {
|
||||
- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception);
|
||||
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); // CraftBukkit - decompile error
|
||||
@@ -68,7 +68,7 @@
|
||||
sourceblock.level().gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, sourceblock.pos());
|
||||
return itemstack;
|
||||
}
|
||||
@@ -120,13 +164,41 @@
|
||||
@@ -116,13 +160,41 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
@@ -103,7 +103,7 @@
|
||||
Consumer<EntityArmorStand> consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> {
|
||||
entityarmorstand.setYRot(enumdirection.toYRot());
|
||||
}, worldserver, itemstack, (EntityHuman) null);
|
||||
EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EnumMobSpawn.DISPENSER, false, false);
|
||||
EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false);
|
||||
|
||||
if (entityarmorstand != null) {
|
||||
- itemstack.shrink(1);
|
||||
@@ -111,7 +111,7 @@
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
@@ -145,7 +217,34 @@
|
||||
@@ -141,7 +213,34 @@
|
||||
});
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
@@ -137,7 +137,7 @@
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
@@ -147,44 +147,7 @@
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
} else {
|
||||
@@ -172,7 +271,35 @@
|
||||
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
|
||||
} while (!entityhorseabstract.isBodyArmorItem(itemstack) || entityhorseabstract.isWearingBodyArmor() || !entityhorseabstract.isTamed());
|
||||
|
||||
- entityhorseabstract.setBodyArmorItem(itemstack.split(1));
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ WorldServer world = sourceblock.level();
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityhorseabstract.setBodyArmorItem(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -215,9 +342,35 @@
|
||||
@@ -166,9 +265,35 @@
|
||||
}
|
||||
|
||||
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
|
||||
@@ -210,7 +173,7 @@
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
@@ -222,7 +185,7 @@
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -249,6 +402,38 @@
|
||||
@@ -202,6 +327,38 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
|
||||
@@ -261,7 +224,7 @@
|
||||
if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) {
|
||||
dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition);
|
||||
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET));
|
||||
@@ -276,7 +461,7 @@
|
||||
@@ -229,7 +386,7 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof IFluidSource ifluidsource) {
|
||||
@@ -270,7 +233,7 @@
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
return super.execute(sourceblock, itemstack);
|
||||
@@ -284,6 +469,32 @@
|
||||
@@ -237,6 +394,32 @@
|
||||
worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
Item item = itemstack1.getItem();
|
||||
|
||||
@@ -303,7 +266,7 @@
|
||||
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item));
|
||||
}
|
||||
} else {
|
||||
@@ -296,16 +507,44 @@
|
||||
@@ -249,16 +432,44 @@
|
||||
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
|
||||
@@ -351,7 +314,7 @@
|
||||
BlockTNT.explode(worldserver, blockposition);
|
||||
worldserver.removeBlock(blockposition, false);
|
||||
} else {
|
||||
@@ -330,12 +569,62 @@
|
||||
@@ -283,12 +494,62 @@
|
||||
this.setSuccess(true);
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
@@ -414,7 +377,7 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -345,12 +634,41 @@
|
||||
@@ -298,12 +559,41 @@
|
||||
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
@@ -458,7 +421,7 @@
|
||||
return itemstack;
|
||||
}
|
||||
});
|
||||
@@ -375,6 +693,30 @@
|
||||
@@ -314,6 +604,30 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
|
||||
|
||||
@@ -489,7 +452,7 @@
|
||||
if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) {
|
||||
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3);
|
||||
worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition);
|
||||
@@ -400,6 +742,30 @@
|
||||
@@ -339,6 +653,30 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
|
||||
|
||||
@@ -520,7 +483,7 @@
|
||||
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
|
||||
if (!worldserver.isClientSide) {
|
||||
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
|
||||
@@ -438,6 +804,30 @@
|
||||
@@ -377,6 +715,30 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
IBlockData iblockdata = worldserver.getBlockState(blockposition);
|
||||
|
||||
@@ -551,7 +514,7 @@
|
||||
if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> {
|
||||
return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive;
|
||||
}) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) {
|
||||
@@ -487,6 +877,31 @@
|
||||
@@ -426,6 +788,31 @@
|
||||
this.setSuccess(false);
|
||||
return itemstack;
|
||||
} else {
|
||||
@@ -574,7 +537,7 @@
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
@@ -16,6 +16,12 @@
|
||||
import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class MinecartDispenseItemBehavior extends DispenseBehaviorItem {
|
||||
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
|
||||
@@ -62,11 +68,40 @@
|
||||
}
|
||||
|
||||
Vec3D vec3d1 = new Vec3D(d0, d1 + d3, d2);
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null);
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(vec3d1.x, vec3d1.y, vec3d1.z));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.entityType, EntitySpawnReason.DISPENSER, itemstack1, (EntityHuman) null);
|
||||
|
||||
if (entityminecartabstract != null) {
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
Reference in New Issue
Block a user