Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemArmor.java
+++ b/net/minecraft/world/item/ItemArmor.java
@@ -25,6 +25,11 @@
@@ -28,6 +28,11 @@
import net.minecraft.world.level.block.BlockDispenser;
import net.minecraft.world.phys.AxisAlignedBB;
@@ -11,10 +11,10 @@
+
public class ItemArmor extends Item implements ItemWearable {
private static final UUID[] j = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
@@ -51,6 +56,32 @@
private static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
@@ -54,6 +59,32 @@
EntityLiving entityliving = (EntityLiving) list.get(0);
EnumItemSlot enumitemslot = EntityInsentient.j(itemstack);
EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
@@ -35,8 +35,8 @@
+ itemstack.add(1);
+ // 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 != ItemArmor.a) {
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ return true;
+ }

View File

@@ -9,6 +9,6 @@
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
world.addEntity(entityarmorstand);
world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F);
}
worldserver.addAllEntities(entityarmorstand);
world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F);
world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, (Entity) entityarmorstand);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/item/ItemBlock.java
+++ b/net/minecraft/world/item/ItemBlock.java
@@ -25,6 +25,13 @@
import net.minecraft.world.level.block.state.properties.IBlockState;
@@ -34,6 +34,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+// CraftBukkit start
@@ -13,8 +13,8 @@
+
public class ItemBlock extends Item {
@Deprecated
@@ -52,6 +59,12 @@
public static final String BLOCK_ENTITY_TAG = "BlockEntityTag";
@@ -69,6 +76,12 @@
return EnumInteractionResult.FAIL;
} else {
IBlockData iblockdata = this.c(blockactioncontext1);
@@ -27,10 +27,10 @@
if (iblockdata == null) {
return EnumInteractionResult.FAIL;
@@ -69,6 +82,15 @@
@@ -85,6 +98,15 @@
iblockdata1 = this.a(blockposition, world, itemstack, iblockdata1);
this.a(blockposition, world, entityhuman, itemstack, iblockdata1);
block.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack);
iblockdata1.getBlock().postPlace(world, blockposition, iblockdata1, entityhuman, itemstack);
+ // CraftBukkit start
+ if (blockstate != null) {
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((WorldServer) world, entityhuman, blockactioncontext1.getHand(), blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ());
@@ -41,20 +41,21 @@
+ }
+ // CraftBukkit end
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition, itemstack);
CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition, itemstack);
}
@@ -76,8 +98,8 @@
@@ -92,9 +114,9 @@
SoundEffectType soundeffecttype = iblockdata1.getStepSound();
- world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
- if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
+ // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
+ if ((entityhuman == null || !entityhuman.abilities.canInstantlyBuild) && itemstack != ItemStack.b) { // CraftBukkit
world.a((Entity) entityhuman, GameEvent.BLOCK_PLACE, blockposition);
- if (entityhuman == null || !entityhuman.getAbilities().instabuild) {
+ if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit
itemstack.subtract(1);
}
@@ -113,6 +135,21 @@
@@ -130,6 +152,21 @@
if (nbttagcompound != null) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag");
@@ -76,7 +77,7 @@
BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStates();
Iterator iterator = nbttagcompound1.getKeys().iterator();
@@ -127,11 +164,6 @@
@@ -144,11 +181,6 @@
}
}
}
@@ -88,7 +89,7 @@
return iblockdata1;
}
@@ -144,8 +176,15 @@
@@ -161,8 +193,15 @@
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
EntityHuman entityhuman = blockactioncontext.getEntity();
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
@@ -105,3 +106,12 @@
}
protected boolean isCheckCollisions() {
@@ -247,7 +286,7 @@
if (nbttagcompound != null) {
NBTTagList nbttaglist = nbttagcompound.getCompound("BlockEntityTag").getList("Items", 10);
- Stream stream = nbttaglist.stream();
+ Stream<net.minecraft.nbt.NBTBase> stream = nbttaglist.stream(); // CraftBukkit - decompile error
Objects.requireNonNull(NBTTagCompound.class);
ItemLiquidUtil.a(entityitem, stream.map(NBTTagCompound.class::cast).map(ItemStack::a));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemBoat.java
+++ b/net/minecraft/world/item/ItemBoat.java
@@ -54,6 +54,13 @@
@@ -56,6 +56,13 @@
}
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
@@ -13,8 +13,8 @@
+ // CraftBukkit end
EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z);
entityboat.setType(this.b);
@@ -62,7 +69,15 @@
entityboat.setType(this.type);
@@ -64,7 +71,15 @@
return InteractionResultWrapper.fail(itemstack);
} else {
if (!world.isClientSide) {
@@ -28,6 +28,6 @@
+ return InteractionResultWrapper.pass(itemstack);
+ }
+ // CraftBukkit end
if (!entityhuman.abilities.canInstantlyBuild) {
world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, new BlockPosition(movingobjectpositionblock.getPos()));
if (!entityhuman.getAbilities().instabuild) {
itemstack.subtract(1);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemBoneMeal.java
+++ b/net/minecraft/world/item/ItemBoneMeal.java
@@ -28,6 +28,12 @@
@@ -35,6 +35,12 @@
@Override
public EnumInteractionResult a(ItemActionContext itemactioncontext) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/item/ItemBow.java
+++ b/net/minecraft/world/item/ItemBow.java
@@ -61,6 +61,14 @@
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
@@ -64,6 +64,14 @@
if (EnchantmentManager.getEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) {
entityarrow.setOnFire(100);
}
+ // CraftBukkit start
@@ -15,8 +15,8 @@
itemstack.damage(1, entityhuman, (entityhuman1) -> {
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
@@ -69,7 +77,16 @@
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
@@ -72,7 +80,16 @@
entityarrow.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
- world.addEntity(entityarrow);
@@ -32,4 +32,4 @@
+ // CraftBukkit end
}
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemBucket.java
+++ b/net/minecraft/world/item/ItemBucket.java
@@ -29,6 +29,16 @@
@@ -31,6 +31,16 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionBlock;
@@ -14,63 +14,65 @@
+import org.bukkit.event.player.PlayerBucketFillEvent;
+// CraftBukkit end
+
public class ItemBucket extends Item {
public class ItemBucket extends Item implements DispensibleContainerItem {
public final FluidType fluidType;
@@ -59,12 +69,22 @@
if (this.fluidType == FluidTypes.EMPTY) {
public final FluidType content;
@@ -61,6 +71,16 @@
iblockdata = world.getType(blockposition);
if (iblockdata.getBlock() instanceof IFluidSource) {
IFluidSource ifluidsource = (IFluidSource) iblockdata.getBlock();
+ // CraftBukkit start
+ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.a());
+ ItemStack dummyFluid = ifluidsource.removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem());
+
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
+ return InteractionResultWrapper.fail(itemstack);
+ }
+ // CraftBukkit end
FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition, iblockdata);
ItemStack itemstack1 = ifluidsource.removeFluid(world, blockposition, iblockdata);
if (fluidtype != FluidTypes.EMPTY) {
entityhuman.b(StatisticList.ITEM_USED.b(this));
entityhuman.playSound(fluidtype.a((Tag) TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F);
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(fluidtype.a()));
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
if (!itemstack1.isEmpty()) {
@@ -69,7 +89,7 @@
entityhuman.playSound(soundeffect, 1.0F, 1.0F);
});
world.a((Entity) entityhuman, GameEvent.FLUID_PICKUP, blockposition);
- ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, itemstack1);
+ ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
if (!world.isClientSide) {
CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.a()));
@@ -79,7 +99,7 @@
CriterionTriggers.FILLED_BUCKET.a((EntityPlayer) entityhuman, itemstack1);
@@ -84,7 +104,7 @@
iblockdata = world.getType(blockposition);
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : blockposition1;
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1;
- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1)) {
+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1, movingobjectpositionblock1.getDirection(), blockposition, itemstack)) { // CraftBukkit
this.a(world, itemstack, blockposition2);
- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock)) {
+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit
this.a(entityhuman, world, itemstack, blockposition2);
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition2, itemstack);
@@ -104,6 +124,11 @@
public void a(World world, ItemStack itemstack, BlockPosition blockposition) {}
CriterionTriggers.PLACED_BLOCK.a((EntityPlayer) entityhuman, blockposition2, itemstack);
@@ -111,6 +131,11 @@
@Override
public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
+ return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null);
+ }
+
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
+ // CraftBukkit end
if (!(this.fluidType instanceof FluidTypeFlowing)) {
if (!(this.content instanceof FluidTypeFlowing)) {
return false;
} else {
@@ -113,8 +138,18 @@
boolean flag = iblockdata.a(this.fluidType);
boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.fluidType);
@@ -120,8 +145,18 @@
boolean flag = iblockdata.a(this.content);
boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.content);
+ // CraftBukkit start
+ if (flag1 && entityhuman != null) {
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack);
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
+ return false;
+ }
@@ -79,6 +81,6 @@
if (!flag1) {
- return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null);
+ return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit
} else if (world.getDimensionManager().isNether() && this.fluidType.a((Tag) TagsFluid.WATER)) {
} else if (world.getDimensionManager().isNether() && this.content.a((Tag) TagsFluid.WATER)) {
int i = blockposition.getX();
int j = blockposition.getY();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemChorusFruit.java
+++ b/net/minecraft/world/item/ItemChorusFruit.java
@@ -33,7 +33,16 @@
@@ -34,7 +34,16 @@
entityliving.stopRiding();
}
@@ -15,6 +15,6 @@
+
+ if (status.get()) {
+ // CraftBukkit end
SoundEffect soundeffect = entityliving instanceof EntityFox ? SoundEffects.ENTITY_FOX_TELEPORT : SoundEffects.ITEM_CHORUS_FRUIT_TELEPORT;
SoundEffect soundeffect = entityliving instanceof EntityFox ? SoundEffects.FOX_TELEPORT : SoundEffects.CHORUS_FRUIT_TELEPORT;
world.playSound((EntityHuman) null, d0, d1, d2, soundeffect, SoundCategory.PLAYERS, 1.0F, 1.0F);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemCrossbow.java
+++ b/net/minecraft/world/item/ItemCrossbow.java
@@ -97,6 +97,10 @@
@@ -114,6 +114,10 @@
if (itemstack1.isEmpty() && flag) {
itemstack1 = new ItemStack(Items.ARROW);
itemstack2 = itemstack1.cloneItemStack();
@@ -11,7 +11,7 @@
}
if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) {
@@ -221,11 +225,27 @@
@@ -238,11 +242,27 @@
vector3fa.a(quaternion);
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
}
@@ -37,6 +37,6 @@
+ }
+ }
+ // CraftBukkit end
world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.ITEM_CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
}
}

View File

@@ -5,7 +5,7 @@
package net.minecraft.world.item;
import java.util.Collection;
@@ -91,7 +92,7 @@
@@ -97,7 +98,7 @@
}
private static <T extends Comparable<T>> IBlockData a(IBlockData iblockdata, IBlockState<T> iblockstate, boolean flag) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemDye.java
+++ b/net/minecraft/world/item/ItemDye.java
@@ -8,6 +8,8 @@
@@ -11,6 +11,8 @@
import net.minecraft.world.entity.animal.EntitySheep;
import net.minecraft.world.entity.player.EntityHuman;
@@ -8,16 +8,16 @@
+
public class ItemDye extends Item {
private static final Map<EnumColor, ItemDye> a = Maps.newEnumMap(EnumColor.class);
@@ -26,7 +28,17 @@
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) {
if (!entityhuman.world.isClientSide) {
- entitysheep.setColor(this.b);
private static final Map<EnumColor, ItemDye> ITEM_BY_COLOR = Maps.newEnumMap(EnumColor.class);
@@ -30,7 +32,17 @@
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.dyeColor) {
entitysheep.level.playSound(entityhuman, (Entity) entitysheep, SoundEffects.DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F);
if (!entityhuman.level.isClientSide) {
- entitysheep.setColor(this.dyeColor);
+ // CraftBukkit start
+ byte bColor = (byte) this.b.getColorIndex();
+ byte bColor = (byte) this.dyeColor.getColorIndex();
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
+ entitysheep.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;

View File

@@ -4,13 +4,13 @@
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
if (!world.isClientSide) {
EntityEgg entityegg = new EntityEgg(world, entityhuman);
entityegg.setItem(itemstack);
entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
entityegg.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
- world.addEntity(entityegg);
+ // CraftBukkit start
+ if (!world.addEntity(entityegg)) {
@@ -21,7 +21,7 @@
+ }
+ // CraftBukkit end
}
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
entityhuman.b(StatisticList.ITEM_USED.b(this));
if (!entityhuman.abilities.canInstantlyBuild) {
if (!entityhuman.getAbilities().instabuild) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemEndCrystal.java
+++ b/net/minecraft/world/item/ItemEndCrystal.java
@@ -45,6 +45,11 @@
@@ -46,6 +46,11 @@
EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D);
entityendercrystal.setShowingBottom(false);
@@ -10,5 +10,5 @@
+ }
+ // CraftBukkit end
world.addEntity(entityendercrystal);
world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition1);
EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonBattle();

View File

@@ -11,5 +11,5 @@
+ }
+ // CraftBukkit end
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.m.a((EntityPlayer) entityhuman, blockposition);
CriterionTriggers.USED_ENDER_EYE.a((EntityPlayer) entityhuman, blockposition);
}

View File

@@ -4,14 +4,14 @@
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
- entityhuman.getCooldownTracker().setCooldown(this, 20);
+ // CraftBukkit start - change order
if (!world.isClientSide) {
EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman);
entityenderpearl.setItem(itemstack);
entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
entityenderpearl.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
- world.addEntity(entityenderpearl);
+ if (!world.addEntity(entityenderpearl)) {
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
@@ -21,10 +21,10 @@
+ }
}
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ entityhuman.getCooldownTracker().setCooldown(this, 20);
+ // CraftBukkit end
+
entityhuman.b(StatisticList.ITEM_USED.b(this));
if (!entityhuman.abilities.canInstantlyBuild) {
if (!entityhuman.getAbilities().instabuild) {
itemstack.subtract(1);

View File

@@ -1,26 +1,12 @@
--- a/net/minecraft/world/item/ItemFireball.java
+++ b/net/minecraft/world/item/ItemFireball.java
@@ -26,12 +26,28 @@
boolean flag = false;
if (BlockCampfire.h(iblockdata)) {
+ // CraftBukkit start - fire BlockIgniteEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) {
+ itemactioncontext.getItemStack().subtract(1);
+ }
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.a(world, blockposition);
world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, true));
flag = true;
} else {
@@ -34,12 +34,28 @@
if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) {
blockposition = blockposition.shift(itemactioncontext.getClickedFace());
if (BlockFireAbstract.a(world, blockposition, itemactioncontext.f())) {
if (BlockFireAbstract.a(world, blockposition, itemactioncontext.g())) {
+ // CraftBukkit start - fire BlockIgniteEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) {
+ if (!itemactioncontext.getEntity().getAbilities().instabuild) {
+ itemactioncontext.getItemStack().subtract(1);
+ }
+ return EnumInteractionResult.PASS;
@@ -28,4 +14,18 @@
+ // CraftBukkit end
this.a(world, blockposition);
world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition));
world.a((Entity) itemactioncontext.getEntity(), GameEvent.BLOCK_PLACE, blockposition);
flag = true;
}
} else {
+ // CraftBukkit start - fire BlockIgniteEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
+ if (!itemactioncontext.getEntity().getAbilities().instabuild) {
+ itemactioncontext.getItemStack().subtract(1);
+ }
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.a(world, blockposition);
world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true));
world.a((Entity) itemactioncontext.getEntity(), GameEvent.BLOCK_PLACE, blockposition);

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/world/item/ItemFishingRod.java
+++ b/net/minecraft/world/item/ItemFishingRod.java
@@ -10,6 +10,8 @@
import net.minecraft.world.item.enchantment.EnchantmentManager;
@@ -12,6 +12,8 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.gameevent.GameEvent;
+import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
+
public class ItemFishingRod extends Item implements ItemVanishable {
public ItemFishingRod(Item.Info item_info) {
@@ -31,12 +33,23 @@
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
@@ -34,12 +36,23 @@
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
world.a((Entity) entityhuman, GameEvent.FISHING_ROD_REEL_IN, (Entity) entityhuman);
} else {
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
if (!world.isClientSide) {
i = EnchantmentManager.c(itemstack);
int j = EnchantmentManager.b(itemstack);
@@ -26,10 +26,10 @@
+ world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ entityhuman.hookedFish = null;
+ entityhuman.fishing = null;
+ return InteractionResultWrapper.pass(itemstack);
+ }
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ world.addEntity(entityfishinghook);
+ // CraftBukkit end
}

View File

@@ -1,18 +1,9 @@
--- a/net/minecraft/world/item/ItemFlintAndSteel.java
+++ b/net/minecraft/world/item/ItemFlintAndSteel.java
@@ -28,7 +28,7 @@
BlockPosition blockposition = itemactioncontext.getClickPosition();
IBlockData iblockdata = world.getType(blockposition);
- if (BlockCampfire.h(iblockdata)) {
+ if (BlockCampfire.h(iblockdata) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entityhuman).isCancelled()) { // CraftBukkit
world.playSound(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11);
if (entityhuman != null) {
@@ -42,6 +42,14 @@
@@ -36,6 +36,14 @@
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());
if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.f())) {
if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.g())) {
+ // CraftBukkit start - Store the clicked block
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
+ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> {
@@ -21,6 +12,21 @@
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
world.playSound(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F);
world.playSound(entityhuman, blockposition1, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F);
IBlockData iblockdata1 = BlockFireAbstract.a((IBlockAccess) world, blockposition1);
@@ -55,6 +63,14 @@
return EnumInteractionResult.FAIL;
}
} else {
+ // CraftBukkit start - Store the clicked block
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
+ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> {
+ entityhuman1.broadcastItemBreak(itemactioncontext.getHand());
+ });
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
world.playSound(entityhuman, blockposition, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.LIT, true), 11);
world.a((Entity) entityhuman, GameEvent.BLOCK_PLACE, blockposition);

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/ItemHanging.java
+++ b/net/minecraft/world/item/ItemHanging.java
@@ -13,6 +13,11 @@
import net.minecraft.world.item.context.ItemActionContext;
@@ -15,6 +15,11 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.entity.Player;
@@ -11,8 +11,8 @@
+
public class ItemHanging extends Item {
private final EntityTypes<? extends EntityHanging> a;
@@ -54,6 +59,18 @@
private final EntityTypes<? extends EntityHanging> type;
@@ -58,6 +63,18 @@
if (((EntityHanging) object).survives()) {
if (!world.isClientSide) {
@@ -29,5 +29,5 @@
+ }
+ // CraftBukkit end
((EntityHanging) object).playPlaceSound();
world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, blockposition);
world.addEntity((Entity) object);
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/item/ItemLeash.java
+++ b/net/minecraft/world/item/ItemLeash.java
@@ -14,6 +14,8 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.AxisAlignedBB;
+import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit
@@ -9,10 +9,10 @@
public class ItemLeash extends Item {
public ItemLeash(Item.Info item_info) {
@@ -55,7 +57,23 @@
@@ -55,9 +57,25 @@
if (entityinsentient.getLeashHolder() == entityhuman) {
if (entityleash == null) {
entityleash = EntityLeash.a(world, blockposition);
entityleash = EntityLeash.b(world, blockposition);
+
+ // CraftBukkit start - fire HangingPlaceEvent
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF);
@@ -23,13 +23,15 @@
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
+ }
+
entityleash.playPlaceSound();
}
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) {
+ continue;
}
+ }
+ // CraftBukkit end
+
entityinsentient.setLeashHolder(entityleash, true);
flag = true;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemMilkBucket.java
+++ b/net/minecraft/world/item/ItemMilkBucket.java
@@ -29,7 +29,7 @@
@@ -31,7 +31,7 @@
}
if (!world.isClientSide) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/ItemMinecart.java
+++ b/net/minecraft/world/item/ItemMinecart.java
@@ -18,6 +18,11 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -20,6 +20,11 @@
import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -11,12 +11,12 @@
+
public class ItemMinecart extends Item {
private static final IDispenseBehavior a = new DispenseBehaviorItem() {
@@ -56,14 +61,43 @@
private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
@@ -58,14 +63,43 @@
}
}
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b);
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type);
+ // CraftBukkit start
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b);
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
@@ -37,15 +37,15 @@
+ itemstack.add(1);
+ // 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 idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).b);
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type);
if (itemstack.hasName()) {
entityminecartabstract.setCustomName(itemstack.getName());
@@ -59,7 +59,7 @@
return itemstack;
}
@@ -105,7 +139,12 @@
@@ -107,7 +141,12 @@
entityminecartabstract.setCustomName(itemstack.getName());
}
@@ -70,6 +70,6 @@
+ }
+ // CraftBukkit end
+ if (!world.addEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
world.a((Entity) itemactioncontext.getEntity(), GameEvent.ENTITY_PLACE, blockposition);
}
itemstack.subtract(1);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemMonsterEgg.java
+++ b/net/minecraft/world/item/ItemMonsterEgg.java
@@ -167,7 +167,7 @@
@@ -179,7 +179,7 @@
return Optional.empty();
} else {
((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F);
@@ -9,7 +9,7 @@
if (itemstack.hasName()) {
((EntityInsentient) object).setCustomName(itemstack.getName());
}
@@ -176,7 +176,7 @@
@@ -188,7 +188,7 @@
itemstack.subtract(1);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemPotion.java
+++ b/net/minecraft/world/item/ItemPotion.java
@@ -46,7 +46,7 @@
@@ -52,7 +52,7 @@
if (mobeffect.getMobEffect().isInstant()) {
mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
} else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemRecord.java
+++ b/net/minecraft/world/item/ItemRecord.java
@@ -37,6 +37,7 @@
@@ -43,6 +43,7 @@
ItemStack itemstack = itemactioncontext.getItemStack();
if (!world.isClientSide) {

View File

@@ -1,10 +1,11 @@
--- a/net/minecraft/world/item/ItemSkullPlayer.java
+++ b/net/minecraft/world/item/ItemSkullPlayer.java
@@ -50,6 +50,15 @@
nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile));
return true;
} else {
@@ -51,6 +51,16 @@
TileEntitySkull.a(gameprofile, (gameprofile1) -> {
nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile1));
});
+ // CraftBukkit start
+ } else {
+ net.minecraft.nbt.NBTTagList textures = nbttagcompound.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
+ for (int i = 0; i < textures.size(); i++) {
+ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).hasKeyOfType("Signature", 8) && ((NBTTagCompound) textures.get(i)).getString("Value").trim().isEmpty()) {
@@ -13,6 +14,6 @@
+ }
+ }
+ // CraftBukkit end
return false;
}
}

View File

@@ -4,21 +4,21 @@
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // CraftBukkit - moved down
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
if (!world.isClientSide) {
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
entitysnowball.setItem(itemstack);
entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
entitysnowball.a(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
- world.addEntity(entitysnowball);
+ if (world.addEntity(entitysnowball)) {
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ if (!entityhuman.getAbilities().instabuild) {
+ itemstack.subtract(1);
+ }
+
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
@@ -28,10 +28,10 @@
entityhuman.b(StatisticList.ITEM_USED.b(this));
+ // CraftBukkit start - moved up
+ /*
if (!entityhuman.abilities.canInstantlyBuild) {
if (!entityhuman.getAbilities().instabuild) {
itemstack.subtract(1);
}
+ */
return InteractionResultWrapper.a(itemstack, world.s_());
return InteractionResultWrapper.a(itemstack, world.isClientSide());
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -58,6 +58,39 @@
@@ -76,6 +76,39 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -39,17 +39,17 @@
+
public final class ItemStack {
public static final Codec<ItemStack> a = RecordCodecBuilder.create((instance) -> {
@@ -71,7 +104,7 @@
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
@@ -89,7 +122,7 @@
});
private static final Logger LOGGER = LogManager.getLogger();
public static final ItemStack b = new ItemStack((Item) null);
- public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> {
+ public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error
public static final ItemStack EMPTY = new ItemStack((Item) null);
- public static final DecimalFormat ATTRIBUTE_MODIFIER_FORMAT = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> {
+ public static final DecimalFormat ATTRIBUTE_MODIFIER_FORMAT = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error
decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT));
});
private static final ChatModifier e = ChatModifier.a.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true);
@@ -106,23 +139,42 @@
public static final String TAG_ENCH = "Enchantments";
@@ -142,16 +175,30 @@
this.checkEmpty();
}
@@ -58,15 +58,15 @@
+ if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) {
+ NBTTagCompound savedStack = new NBTTagCompound();
+ this.save(savedStack);
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().fixerUpper.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.INSTANCE, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
+ this.load(savedStack);
+ }
+ }
+
private void checkEmpty() {
+ if (this.j && this == ItemStack.b) throw new AssertionError("TRAP"); // CraftBukkit
this.j = false;
this.j = this.isEmpty();
+ if (this.emptyCacheFlag && this == ItemStack.EMPTY) throw new AssertionError("TRAP"); // CraftBukkit
this.emptyCacheFlag = false;
this.emptyCacheFlag = this.isEmpty();
}
- private ItemStack(NBTTagCompound nbttagcompound) {
@@ -76,14 +76,13 @@
this.count = nbttagcompound.getByte("Count");
if (nbttagcompound.hasKeyOfType("tag", 10)) {
- this.tag = nbttagcompound.getCompound("tag");
- this.getItem().b(nbttagcompound);
+ // CraftBukkit start - make defensive copy as this data may be coming from the save thread
+ this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone();
+ this.getItem().b(this.tag);
+ // CraftBukkit end
this.getItem().b(this.tag);
}
if (this.getItem().usesDurability()) {
@@ -159,6 +206,11 @@
this.setDamage(this.getDamage());
}
@@ -95,8 +94,8 @@
this.checkEmpty();
}
@@ -152,7 +204,7 @@
return this.j ? Items.AIR : this.item;
@@ -196,7 +248,7 @@
return this.getItem() == item;
}
- public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) {
@@ -104,8 +103,8 @@
EntityHuman entityhuman = itemactioncontext.getEntity();
BlockPosition blockposition = itemactioncontext.getClickPosition();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
@@ -160,12 +212,153 @@
if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().p(), shapedetectorblock)) {
@@ -204,12 +256,153 @@
if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.b(itemactioncontext.getWorld().r(), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
+ // CraftBukkit start - handle all block place event logic here
@@ -160,7 +159,7 @@
+ }
+ world.captureTreeGeneration = false;
if (entityhuman != null && enuminteractionresult.a()) {
if (entityhuman != null && enuminteractionresult.c()) {
- entityhuman.b(StatisticList.ITEM_USED.b(item));
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
@@ -183,7 +182,7 @@
+ // Brute force all possible updates
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ for (EnumDirection dir : EnumDirection.values()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir)));
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir)));
+ }
+ } else {
+ // Change the stack to its new contents if it hasn't been tampered with.
@@ -193,7 +192,7 @@
+ }
+
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
+ world.setTileEntity(e.getKey(), e.getValue());
+ world.setTileEntity(e.getValue());
+ }
+
+ for (BlockState blockstate : blocks) {
@@ -259,7 +258,7 @@
return enuminteractionresult;
}
@@ -246,6 +439,21 @@
@@ -290,6 +483,21 @@
}
i -= k;
@@ -281,7 +280,7 @@
if (i <= 0) {
return false;
}
@@ -267,6 +475,11 @@
@@ -311,6 +519,11 @@
if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
consumer.accept(t0);
Item item = this.getItem();
@@ -293,7 +292,7 @@
this.subtract(1);
if (t0 instanceof EntityHuman) {
@@ -398,6 +611,17 @@
@@ -466,6 +679,17 @@
return this.tag;
}
@@ -311,7 +310,7 @@
public NBTTagCompound getOrCreateTag() {
if (this.tag == null) {
this.setTag(new NBTTagCompound());
@@ -561,6 +785,12 @@
@@ -849,6 +1073,12 @@
}
public void setRepairCost(int i) {
@@ -324,7 +323,7 @@
this.getOrCreateTag().setInt("RepairCost", i);
}
@@ -610,6 +840,13 @@
@@ -898,6 +1128,13 @@
nbttaglist.add(nbttagcompound);
}
@@ -335,6 +334,6 @@
+ }
+ // CraftBukkit end
+
public IChatBaseComponent C() {
public IChatBaseComponent G() {
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).addSibling(this.getName());

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemTrident.java
+++ b/net/minecraft/world/item/ItemTrident.java
@@ -65,9 +65,12 @@
@@ -68,9 +68,12 @@
if (k <= 0 || entityhuman.isInWaterOrRain()) {
if (!world.isClientSide) {
@@ -13,8 +13,8 @@
if (k == 0) {
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
@@ -76,16 +79,39 @@
entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
@@ -79,16 +82,39 @@
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
- world.addEntity(entitythrowntrident);
@@ -29,12 +29,12 @@
+ itemstack.damage(1, entityhuman, (entityhuman1) -> {
+ entityhuman1.broadcastItemBreak(entityliving.getRaisedHand());
+ });
+ entitythrowntrident.trident = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved
+ entitythrowntrident.tridentItem = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved
+ // CraftBukkit end
+
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
if (!entityhuman.abilities.canInstantlyBuild) {
entityhuman.inventory.f(itemstack);
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
if (!entityhuman.getAbilities().instabuild) {
entityhuman.getInventory().g(itemstack);
}
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
+ } else {
@@ -51,6 +51,6 @@
+ org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
float f = entityhuman.yaw;
float f1 = entityhuman.pitch;
float f = entityhuman.getYRot();
float f1 = entityhuman.getXRot();
float f2 = -MathHelper.sin(f * 0.017453292F) * MathHelper.cos(f1 * 0.017453292F);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemWorldMap.java
+++ b/net/minecraft/world/item/ItemWorldMap.java
@@ -30,6 +30,11 @@
@@ -34,6 +34,11 @@
import net.minecraft.world.level.material.MaterialMapColor;
import net.minecraft.world.level.saveddata.maps.WorldMap;
@@ -11,25 +11,24 @@
+
public class ItemWorldMap extends ItemWorldMapBase {
public ItemWorldMap(Item.Info item_info) {
@@ -62,7 +67,7 @@
public static int d(ItemStack itemstack) {
public static final int IMAGE_WIDTH = 128;
@@ -68,7 +73,7 @@
public static Integer d(ItemStack itemstack) {
NBTTagCompound nbttagcompound = itemstack.getTag();
- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0;
- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : null;
+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
}
private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
@@ -72,6 +77,11 @@
worldmap.a(i, j, k, flag, flag1, resourcekey);
world.a(worldmap);
itemstack.getOrCreateTag().setInt("map", l);
+
private static int a(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
@@ -76,6 +81,10 @@
int l = world.getWorldMapCount();
world.a(a(l), worldmap);
+ // CraftBukkit start
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
return worldmap;
return l;
}

View File

@@ -8,17 +8,17 @@
+
public class CraftingManager extends ResourceDataJson {
private static final Gson a = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
private static final Logger LOGGER = LogManager.getLogger();
- public Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of();
+ public Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of(); // CraftBukkit
private boolean d;
private boolean hasErrors;
public CraftingManager() {
@@ -47,7 +49,12 @@
protected void a(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
this.d = false;
this.hasErrors = false;
- Map<Recipes<?>, Builder<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
+ // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
@@ -29,7 +29,7 @@
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
@@ -57,24 +64,42 @@
@@ -57,28 +64,46 @@
try {
IRecipe<?> irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element"));
@@ -65,6 +65,10 @@
+ }
+ // CraftBukkit end
+
public boolean a() {
return this.hasErrors;
}
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
- return this.b(recipes).values().stream().flatMap((irecipe) -> {
+ // CraftBukkit start
@@ -77,7 +81,7 @@
}
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
@@ -92,7 +117,7 @@
@@ -96,7 +121,7 @@
}
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) {
@@ -86,7 +90,7 @@
}
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> c(Recipes<T> recipes, C c0, World world) {
@@ -113,7 +138,7 @@
@@ -117,7 +142,7 @@
public Optional<? extends IRecipe<?>> getRecipe(MinecraftKey minecraftkey) {
return this.recipes.values().stream().map((map) -> {
@@ -95,9 +99,23 @@
}).filter(Objects::nonNull).findFirst();
}
@@ -136,4 +161,14 @@
return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'");
})).a(minecraftkey, jsonobject);
@@ -143,11 +168,11 @@
public void a(Iterable<IRecipe<?>> iterable) {
this.hasErrors = false;
- Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap();
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap(); // CraftBukkit
iterable.forEach((irecipe) -> {
Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.g(), (recipes) -> {
- return Maps.newHashMap();
+ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
});
IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getKey(), irecipe);
@@ -157,4 +182,14 @@
});
this.recipes = ImmutableMap.copyOf(map);
}
+
+ // CraftBukkit start

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/FurnaceRecipe.java
+++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java
@@ -3,6 +3,14 @@
import net.minecraft.resources.MinecraftKey;
@@ -4,6 +4,14 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
@@ -15,16 +15,16 @@
public class FurnaceRecipe extends RecipeCooking {
public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
@@ -13,4 +21,14 @@
@@ -19,4 +27,14 @@
public RecipeSerializer<?> getRecipeSerializer() {
return RecipeSerializer.p;
return RecipeSerializer.SMELTING_RECIPE;
}
+
+ @Override
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ recipe.setGroup(this.group);
+
+ return recipe;

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/item/crafting/IRecipe.java
+++ b/net/minecraft/world/item/crafting/IRecipe.java
@@ -42,4 +42,6 @@
RecipeSerializer<?> getRecipeSerializer();
Recipes<?> g();
@@ -61,4 +61,6 @@
return recipeitemstack.a().length == 0;
});
}
+
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
}

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
@@ -25,4 +25,11 @@
public ItemStack getResult() {
return ItemStack.b;
return ItemStack.EMPTY;
}
+
+ // CraftBukkit start

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/RecipeBlasting.java
+++ b/net/minecraft/world/item/crafting/RecipeBlasting.java
@@ -3,6 +3,14 @@
import net.minecraft.resources.MinecraftKey;
@@ -4,6 +4,14 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe;
@@ -15,9 +15,9 @@
public class RecipeBlasting extends RecipeCooking {
public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
@@ -13,4 +21,16 @@
@@ -19,4 +27,16 @@
public RecipeSerializer<?> getRecipeSerializer() {
return RecipeSerializer.q;
return RecipeSerializer.BLASTING_RECIPE;
}
+
+ // CraftBukkit start
@@ -25,7 +25,7 @@
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ recipe.setGroup(this.group);
+
+ return recipe;

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/RecipeCampfire.java
+++ b/net/minecraft/world/item/crafting/RecipeCampfire.java
@@ -3,6 +3,14 @@
import net.minecraft.resources.MinecraftKey;
@@ -4,6 +4,14 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe;
@@ -15,9 +15,9 @@
public class RecipeCampfire extends RecipeCooking {
public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
@@ -13,4 +21,16 @@
@@ -19,4 +27,16 @@
public RecipeSerializer<?> getRecipeSerializer() {
return RecipeSerializer.s;
return RecipeSerializer.CAMPFIRE_COOKING_RECIPE;
}
+
+ // CraftBukkit start
@@ -25,7 +25,7 @@
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ recipe.setGroup(this.group);
+
+ return recipe;

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
@@ -35,6 +35,7 @@
private final RecipeItemStack.Provider[] b;
public ItemStack[] choices;
private IntList d;
private final RecipeItemStack.Provider[] values;
public ItemStack[] itemStacks;
private IntList stackingIds;
+ public boolean exact; // CraftBukkit
public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) {
this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
@@ -67,6 +68,15 @@
this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
@@ -72,6 +73,15 @@
for (int j = 0; j < i; ++j) {
ItemStack itemstack1 = aitemstack[j];
@@ -21,6 +21,15 @@
+ continue;
+ }
+ // CraftBukkit end
if (itemstack1.getItem() == itemstack.getItem()) {
if (itemstack1.a(itemstack.getItem())) {
return true;
}
@@ -103,7 +113,7 @@
public void a(PacketDataSerializer packetdataserializer) {
this.buildChoices();
- packetdataserializer.a((Collection) Arrays.asList(this.itemStacks), PacketDataSerializer::a);
+ packetdataserializer.a(Arrays.asList(this.itemStacks), PacketDataSerializer::a); // CraftBukkit - decompile error
}
public JsonElement c() {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/RecipeSmithing.java
+++ b/net/minecraft/world/item/crafting/RecipeSmithing.java
@@ -10,6 +10,14 @@
import net.minecraft.world.item.ItemStack;
@@ -12,6 +12,14 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -14,17 +14,17 @@
+
public class RecipeSmithing implements IRecipe<IInventory> {
private final RecipeItemStack a;
@@ -65,6 +73,17 @@
return Recipes.SMITHING;
final RecipeItemStack base;
@@ -84,6 +92,17 @@
});
}
+ // CraftBukkit start
+ @Override
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.c);
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.d), result, CraftRecipe.toBukkit(this.a), CraftRecipe.toBukkit(this.b));
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
+
+ return recipe;
+ }

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/RecipeSmoking.java
+++ b/net/minecraft/world/item/crafting/RecipeSmoking.java
@@ -3,6 +3,14 @@
import net.minecraft.resources.MinecraftKey;
@@ -4,6 +4,14 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -15,9 +15,9 @@
public class RecipeSmoking extends RecipeCooking {
public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
@@ -13,4 +21,16 @@
@@ -19,4 +27,16 @@
public RecipeSerializer<?> getRecipeSerializer() {
return RecipeSerializer.r;
return RecipeSerializer.SMOKING_RECIPE;
}
+
+ // CraftBukkit start
@@ -25,7 +25,7 @@
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
+ recipe.setGroup(this.group);
+
+ return recipe;

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/crafting/RecipeStonecutting.java
+++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java
@@ -5,6 +5,14 @@
import net.minecraft.world.item.ItemStack;
@@ -6,6 +6,14 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -15,9 +15,9 @@
public class RecipeStonecutting extends RecipeSingleItem {
public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
@@ -15,4 +23,16 @@
public boolean a(IInventory iinventory, World world) {
return this.ingredient.test(iinventory.getItem(0));
@@ -21,4 +29,16 @@
public ItemStack h() {
return new ItemStack(Blocks.STONECUTTER);
}
+
+ // CraftBukkit start
@@ -25,7 +25,7 @@
+ public Recipe toBukkitRecipe() {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient));
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient));
+ recipe.setGroup(this.group);
+
+ return recipe;

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
@@ -22,6 +22,13 @@
import net.minecraft.world.item.ItemStack;
@@ -23,6 +23,13 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.level.World;
+// CraftBukkit start
@@ -13,8 +13,8 @@
+
public class ShapedRecipes implements RecipeCrafting {
private final int width;
@@ -40,6 +47,66 @@
final int width;
@@ -41,6 +48,66 @@
this.result = itemstack;
}
@@ -66,7 +66,7 @@
+ break;
+ }
+ char c = 'a';
+ for (RecipeItemStack list : this.items) {
+ for (RecipeItemStack list : this.recipeItems) {
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
+ if (choice != null) {
+ recipe.setIngredient(c, choice);
@@ -80,4 +80,4 @@
+
@Override
public MinecraftKey getKey() {
return this.key;
return this.id;

View File

@@ -12,7 +12,7 @@
+
public class ShapelessRecipes implements RecipeCrafting {
private final MinecraftKey key;
private final MinecraftKey id;
@@ -28,6 +34,20 @@
this.ingredients = nonnulllist;
}
@@ -33,4 +33,4 @@
+
@Override
public MinecraftKey getKey() {
return this.key;
return this.id;

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
+++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
@@ -60,7 +60,7 @@
if (this.a == 2 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) {
@@ -63,7 +63,7 @@
if (this.type == 2 && i > 0 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) {
int j = 20 + entityliving.getRandom().nextInt(10 * i);
- entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3));
+ entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3));
+ entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/enchantment/Enchantments.java
+++ b/net/minecraft/world/item/enchantment/Enchantments.java
@@ -45,7 +45,15 @@
@@ -45,9 +45,17 @@
public static final Enchantment MENDING = a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values()));
public static final Enchantment VANISHING_CURSE = a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values()));
@@ -12,6 +12,8 @@
+ }
+ // CraftBukkit end
+
public Enchantments() {}
private static Enchantment a(String s, Enchantment enchantment) {
- return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, (Object) enchantment);
+ return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, enchantment); // CraftBukkit - decompile error

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/trading/IMerchant.java
+++ b/net/minecraft/world/item/trading/IMerchant.java
@@ -51,4 +51,6 @@
@@ -53,4 +53,6 @@
}
}

View File

@@ -8,7 +8,7 @@
+
public class MerchantRecipe {
public ItemStack buyingItem1;
public ItemStack baseCostA;
@@ -17,6 +19,18 @@
private int demand;
public float priceMultiplier;
@@ -31,8 +31,8 @@
@@ -78,6 +92,7 @@
public ItemStack getBuyItem1() {
int i = this.buyingItem1.getCount();
+ if (i <= 0) return ItemStack.b; // CraftBukkit - SPIGOT-5476
ItemStack itemstack = this.buyingItem1.cloneItemStack();
int i = this.baseCostA.getCount();
+ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476
ItemStack itemstack = this.baseCostA.cloneItemStack();
int j = Math.max(0, MathHelper.d((float) (i * this.demand) * this.priceMultiplier));