@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemArmor.java
|
||||
+++ b/net/minecraft/world/item/ItemArmor.java
|
||||
@@ -31,6 +31,12 @@
|
||||
@@ -29,6 +29,12 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
+
|
||||
public class ItemArmor extends Item implements Equipable {
|
||||
|
||||
private static final EnumMap<ItemArmor.a, UUID> ARMOR_MODIFIER_UUID_PER_TYPE = (EnumMap) SystemUtils.make(new EnumMap(ItemArmor.a.class), (enummap) -> {
|
||||
@@ -60,8 +66,34 @@
|
||||
public static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -51,8 +57,34 @@
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack);
|
||||
EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
+ // CraftBukkit start
|
||||
+ World world = sourceblock.level();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
public class ItemBucket extends Item implements DispensibleContainerItem {
|
||||
|
||||
public final FluidType content;
|
||||
@@ -62,6 +72,17 @@
|
||||
@@ -63,6 +73,17 @@
|
||||
|
||||
if (block instanceof IFluidSource) {
|
||||
IFluidSource ifluidsource = (IFluidSource) block;
|
||||
@@ -32,10 +32,10 @@
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata);
|
||||
|
||||
itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata);
|
||||
if (!itemstack1.isEmpty()) {
|
||||
@@ -70,7 +91,7 @@
|
||||
@@ -71,7 +92,7 @@
|
||||
entityhuman.playSound(soundeffect, 1.0F, 1.0F);
|
||||
});
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
if (!world.isClientSide) {
|
||||
CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1);
|
||||
@@ -85,7 +106,7 @@
|
||||
@@ -86,7 +107,7 @@
|
||||
iblockdata = world.getBlockState(blockposition);
|
||||
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
this.checkExtraContent(entityhuman, world, itemstack, blockposition2);
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack);
|
||||
@@ -112,6 +133,12 @@
|
||||
@@ -114,6 +135,12 @@
|
||||
|
||||
@Override
|
||||
public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
@@ -66,7 +66,7 @@
|
||||
FluidType fluidtype = this.content;
|
||||
|
||||
if (!(fluidtype instanceof FluidTypeFlowing fluidtypeflowing)) {
|
||||
@@ -147,8 +174,18 @@
|
||||
@@ -149,8 +176,18 @@
|
||||
|
||||
boolean flag2 = flag1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemEnderEye.java
|
||||
+++ b/net/minecraft/world/item/ItemEnderEye.java
|
||||
@@ -95,7 +95,11 @@
|
||||
@@ -97,7 +97,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman));
|
||||
@@ -11,5 +11,5 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.USED_ENDER_EYE.trigger((EntityPlayer) entityhuman, blockposition);
|
||||
}
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemFishingRod.java
|
||||
+++ b/net/minecraft/world/item/ItemFishingRod.java
|
||||
@@ -12,6 +12,11 @@
|
||||
@@ -13,6 +13,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
@@ -12,19 +12,20 @@
|
||||
public class ItemFishingRod extends Item {
|
||||
|
||||
public ItemFishingRod(Item.Info item_info) {
|
||||
@@ -32,12 +37,23 @@
|
||||
@@ -33,13 +38,24 @@
|
||||
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
||||
} else {
|
||||
- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
if (!world.isClientSide) {
|
||||
i = EnchantmentManager.getFishingSpeedBonus(itemstack);
|
||||
int j = EnchantmentManager.getFishingLuckBonus(itemstack);
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F);
|
||||
int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman);
|
||||
|
||||
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i));
|
||||
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, k, j));
|
||||
+ // CraftBukkit start
|
||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i);
|
||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j);
|
||||
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(playerFishEvent);
|
||||
+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemHanging.java
|
||||
+++ b/net/minecraft/world/item/ItemHanging.java
|
||||
@@ -23,6 +23,11 @@
|
||||
@@ -24,6 +24,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ItemHanging extends Item {
|
||||
|
||||
private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY);
|
||||
@@ -73,6 +78,19 @@
|
||||
@@ -74,6 +79,19 @@
|
||||
|
||||
if (((EntityHanging) object).survives()) {
|
||||
if (!world.isClientSide) {
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
--- a/net/minecraft/world/item/ItemLeash.java
|
||||
+++ b/net/minecraft/world/item/ItemLeash.java
|
||||
@@ -16,6 +16,11 @@
|
||||
@@ -19,6 +19,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -32,7 +37,7 @@
|
||||
@@ -35,7 +41,7 @@
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
|
||||
if (!world.isClientSide && entityhuman != null) {
|
||||
@@ -21,28 +22,28 @@
|
||||
}
|
||||
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -41,7 +46,7 @@
|
||||
@@ -44,7 +50,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand
|
||||
EntityLeash entityleash = null;
|
||||
double d0 = 7.0D;
|
||||
int i = blockposition.getX();
|
||||
@@ -54,19 +59,50 @@
|
||||
List<Leashable> list = leashableInArea(world, blockposition, (leashable) -> {
|
||||
return leashable.getLeashHolder() == entityhuman;
|
||||
@@ -52,22 +58,55 @@
|
||||
|
||||
EntityInsentient entityinsentient;
|
||||
Leashable leashable;
|
||||
|
||||
- for (Iterator iterator = list.iterator(); iterator.hasNext(); entityinsentient.setLeashedTo(entityleash, true)) {
|
||||
- for (Iterator iterator = list.iterator(); iterator.hasNext(); leashable.setLeashedTo(entityleash, true)) {
|
||||
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) { // CraftBukkit - handle setLeashedTo at end of loop
|
||||
entityinsentient = (EntityInsentient) iterator.next();
|
||||
leashable = (Leashable) iterator.next();
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||
+ 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, hand);
|
||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, CraftBlock.at(world, blockposition), org.bukkit.block.BlockFace.SELF, hand);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
@@ -54,12 +55,14 @@
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ iterator.remove();
|
||||
+ continue;
|
||||
+ if (leashable instanceof Entity leashed) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(leashed, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ iterator.remove();
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityinsentient.setLeashedTo(entityleash, true);
|
||||
+ leashable.setLeashedTo(entityleash, true);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -75,10 +78,13 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
+ return bindPlayerMobs(entityhuman, world, blockposition, net.minecraft.world.EnumHand.MAIN_HAND);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+
|
||||
public static List<Leashable> leashableInArea(World world, BlockPosition blockposition, Predicate<Leashable> predicate) {
|
||||
double d0 = 7.0D;
|
||||
int i = blockposition.getX();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/item/ItemMilkBucket.java
|
||||
+++ b/net/minecraft/world/item/ItemMilkBucket.java
|
||||
@@ -26,7 +26,7 @@
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
itemstack.consume(1, entityliving);
|
||||
if (!world.isClientSide) {
|
||||
- entityliving.removeAllEffects();
|
||||
+ entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit
|
||||
}
|
||||
|
||||
return itemstack.isEmpty() ? new ItemStack(Items.BUCKET) : itemstack;
|
||||
if (entityliving instanceof EntityHuman entityhuman) {
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
--- a/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
+++ b/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
@@ -59,11 +59,28 @@
|
||||
float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3;
|
||||
|
||||
f5 = -f5;
|
||||
- itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
|
||||
+ // itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); // CraftBukkit - moved down
|
||||
IProjectile iprojectile = this.createProjectile(world, entityliving, itemstack, itemstack1, flag);
|
||||
@@ -62,7 +62,22 @@
|
||||
IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag);
|
||||
|
||||
this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
|
||||
- world.addFreshEntity(iprojectile);
|
||||
- worldserver.addFreshEntity(iprojectile);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, iprojectile, enumhand, f, true);
|
||||
+ if (event.isCancelled()) {
|
||||
@@ -17,10 +12,8 @@
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
|
||||
+
|
||||
+ if (event.getProjectile() == iprojectile.getBukkitEntity()) {
|
||||
+ if (!world.addFreshEntity(iprojectile)) {
|
||||
+ if (!worldserver.addFreshEntity(iprojectile)) {
|
||||
+ if (entityliving instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
@@ -28,6 +21,6 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
|
||||
if (itemstack.isEmpty()) {
|
||||
break;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemRecord.java
|
||||
+++ b/net/minecraft/world/item/ItemRecord.java
|
||||
@@ -47,6 +47,7 @@
|
||||
ItemStack itemstack = itemactioncontext.getItemInHand();
|
||||
|
||||
if (!world.isClientSide) {
|
||||
+ if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
TileEntity tileentity = world.getBlockEntity(blockposition);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -92,6 +92,40 @@
|
||||
@@ -91,6 +91,40 @@
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
public final class ItemStack implements DataComponentHolder {
|
||||
|
||||
public static final Codec<Holder<Item>> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM.holderByNameCodec().validate((holder) -> {
|
||||
@@ -100,14 +134,14 @@
|
||||
@@ -99,14 +133,14 @@
|
||||
}) : DataResult.success(holder);
|
||||
});
|
||||
public static final Codec<ItemStack> CODEC = Codec.lazyInitialized(() -> {
|
||||
- return RecordCodecBuilder.create((instance) -> {
|
||||
+ return RecordCodecBuilder.<ItemStack>create((instance) -> { // CraftBukkit - decompile error
|
||||
return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.POSITIVE_INT.fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return itemstack.components.asPatch();
|
||||
})).apply(instance, ItemStack::new);
|
||||
});
|
||||
@@ -58,7 +58,7 @@
|
||||
return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return itemstack.components.asPatch();
|
||||
})).apply(instance, (holder, datacomponentpatch) -> {
|
||||
@@ -132,19 +166,25 @@
|
||||
@@ -131,19 +165,25 @@
|
||||
if (i <= 0) {
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
@@ -88,7 +88,7 @@
|
||||
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());
|
||||
}
|
||||
}
|
||||
@@ -188,7 +228,7 @@
|
||||
@@ -187,7 +227,7 @@
|
||||
|
||||
return dataresult.isError() ? dataresult.map((unit) -> {
|
||||
return itemstack;
|
||||
@@ -97,7 +97,18 @@
|
||||
int i = itemstack.getCount();
|
||||
|
||||
return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize();
|
||||
@@ -347,11 +387,191 @@
|
||||
@@ -286,8 +326,9 @@
|
||||
j = itemstack.getMaxStackSize();
|
||||
} while (i <= j);
|
||||
|
||||
+ int finalI = i, finalJ = j; // CraftBukkit - decompile error
|
||||
return DataResult.error(() -> {
|
||||
- return "Item stack with count of " + i + " was larger than maximum: " + j;
|
||||
+ return "Item stack with count of " + finalI + " was larger than maximum: " + finalJ; // CraftBukkit - decompile error
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -369,11 +410,169 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
Item item = this.getItem();
|
||||
@@ -213,28 +224,6 @@
|
||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||
+ }
|
||||
+
|
||||
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
|
||||
+ // PAIL: checkme on updates.
|
||||
+ if (this.item instanceof ItemRecord) {
|
||||
+ TileEntity tileentity = world.getBlockEntity(blockposition);
|
||||
+
|
||||
+ if (tileentity instanceof TileEntityJukeBox) {
|
||||
+ TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity;
|
||||
+
|
||||
+ // There can only be one
|
||||
+ ItemStack record = this.copy();
|
||||
+ if (!record.isEmpty()) {
|
||||
+ record.setCount(1);
|
||||
+ }
|
||||
+
|
||||
+ tileentityjukebox.setTheItem(record);
|
||||
+ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entityhuman, world.getBlockState(blockposition)));
|
||||
+ }
|
||||
+
|
||||
+ this.shrink(1);
|
||||
+ entityhuman.awardStat(StatisticList.PLAY_RECORD);
|
||||
+ }
|
||||
+
|
||||
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
|
||||
+ BlockPosition bp = blockposition;
|
||||
+ if (!world.getBlockState(blockposition).canBeReplaced()) {
|
||||
@@ -291,41 +280,41 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -432,6 +652,21 @@
|
||||
}
|
||||
@@ -444,6 +643,21 @@
|
||||
if (entityplayer == null || !entityplayer.hasInfiniteMaterials()) {
|
||||
if (i > 0) {
|
||||
i = EnchantmentManager.processDurabilityChange(worldserver, this, i);
|
||||
+ // CraftBukkit start
|
||||
+ if (entityplayer != null) {
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i);
|
||||
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (i != event.getDamage() || event.isCancelled()) {
|
||||
+ event.getPlayer().updateInventory();
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -480,6 +694,11 @@
|
||||
}
|
||||
|
||||
i -= k;
|
||||
+ // CraftBukkit start
|
||||
+ if (entityplayer != null) {
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i);
|
||||
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (i != event.getDamage() || event.isCancelled()) {
|
||||
+ event.getPlayer().updateInventory();
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -474,6 +709,11 @@
|
||||
this.hurtAndBreak(i, randomsource, entityplayer, () -> {
|
||||
entityliving.broadcastBreakEvent(enumitemslot);
|
||||
Item item = this.getItem();
|
||||
this.hurtAndBreak(i, worldserver, entityplayer, (item) -> {
|
||||
+ // CraftBukkit start - Check for item breaking
|
||||
+ if (this.count == 1 && entityliving instanceof EntityHuman) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.shrink(1);
|
||||
if (entityliving instanceof EntityHuman) {
|
||||
@@ -669,6 +909,12 @@
|
||||
entityliving.onEquippedItemBroken(item, enumitemslot);
|
||||
});
|
||||
}
|
||||
@@ -693,6 +912,12 @@
|
||||
return this.getItem().useOnRelease(this);
|
||||
}
|
||||
|
||||
@@ -338,7 +327,7 @@
|
||||
@Nullable
|
||||
public <T> T set(DataComponentType<? super T> datacomponenttype, @Nullable T t0) {
|
||||
return this.components.set(datacomponenttype, t0);
|
||||
@@ -728,7 +974,7 @@
|
||||
@@ -752,7 +977,7 @@
|
||||
}
|
||||
|
||||
private <T extends TooltipProvider> void addToTooltip(DataComponentType<T> datacomponenttype, Item.b item_b, Consumer<IChatBaseComponent> consumer, TooltipFlag tooltipflag) {
|
||||
@@ -347,8 +336,8 @@
|
||||
|
||||
if (t0 != null) {
|
||||
t0.addToTooltip(item_b, consumer, tooltipflag);
|
||||
@@ -955,6 +1201,13 @@
|
||||
|
||||
@@ -992,6 +1217,13 @@
|
||||
EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -361,7 +350,7 @@
|
||||
public IChatBaseComponent getDisplayName() {
|
||||
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName());
|
||||
|
||||
@@ -1017,7 +1270,7 @@
|
||||
@@ -1054,7 +1286,7 @@
|
||||
}
|
||||
|
||||
public void consume(int i, @Nullable EntityLiving entityliving) {
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
--- a/net/minecraft/world/item/ItemTrident.java
|
||||
+++ b/net/minecraft/world/item/ItemTrident.java
|
||||
@@ -72,7 +72,7 @@
|
||||
@@ -77,7 +77,7 @@
|
||||
Holder<SoundEffect> holder = (Holder) EnchantmentManager.pickHighestLevel(itemstack, EnchantmentEffectComponents.TRIDENT_SOUND).orElse(SoundEffects.TRIDENT_THROW);
|
||||
|
||||
if (k <= 0 || entityhuman.isInWaterOrRain()) {
|
||||
if (!world.isClientSide) {
|
||||
- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down
|
||||
if (k == 0) {
|
||||
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
|
||||
if (!world.isClientSide) {
|
||||
- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down
|
||||
if (f == 0.0F) {
|
||||
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
|
||||
|
||||
@@ -81,11 +81,26 @@
|
||||
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
@@ -86,11 +86,26 @@
|
||||
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
- world.addFreshEntity(entitythrowntrident);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entitythrowntrident)) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
- world.addFreshEntity(entitythrowntrident);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entitythrowntrident)) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.hasInfiniteMaterials()) {
|
||||
entityhuman.getInventory().removeItem(itemstack);
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.hasInfiniteMaterials()) {
|
||||
entityhuman.getInventory().removeItem(itemstack);
|
||||
}
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +117,7 @@
|
||||
f2 *= f6 / f5;
|
||||
f3 *= f6 / f5;
|
||||
f4 *= f6 / f5;
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f2, f3, f4); // CraftBukkit
|
||||
entityhuman.push((double) f2, (double) f3, (double) f4);
|
||||
entityhuman.startAutoSpinAttack(20);
|
||||
if (entityhuman.onGround()) {
|
||||
@@ -106,6 +121,7 @@
|
||||
f3 *= f / f6;
|
||||
f4 *= f / f6;
|
||||
f5 *= f / f6;
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit
|
||||
entityhuman.push((double) f3, (double) f4, (double) f5);
|
||||
entityhuman.startAutoSpinAttack(20, 8.0F, itemstack);
|
||||
if (entityhuman.onGround()) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
@@ -70,19 +75,39 @@
|
||||
@@ -70,11 +75,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,48 +41,32 @@
|
||||
public boolean hadErrorsLoading() {
|
||||
return this.hasErrors;
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, C c0, World world) {
|
||||
- return this.byType(recipes).stream().filter((recipeholder) -> {
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder) -> {
|
||||
return recipeholder.value().matches(c0, world);
|
||||
- }).findFirst();
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ return recipe;
|
||||
+ // CraftBukkit end
|
||||
@@ -90,9 +110,13 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) {
|
||||
@@ -94,9 +119,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- return this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world, @Nullable RecipeHolder<T> recipeholder) {
|
||||
- return i0.isEmpty() ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
return recipeholder1.value().matches(c0, world);
|
||||
- }).findFirst();
|
||||
return recipeholder1.value().matches(i0, world);
|
||||
- }).findFirst());
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty() || i0.isEmpty()) ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ return recipe;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<RecipeHolder<T>> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -112,7 +142,7 @@
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> List<RecipeHolder<T>> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -108,7 +132,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
private <I extends RecipeInput, T extends IRecipe<I>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -139,7 +169,7 @@
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, I i0, World world) {
|
||||
@@ -135,7 +159,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, MinecraftKey minecraftkey) {
|
||||
RecipeHolder<?> recipeholder = (RecipeHolder) this.byName.get(minecraftkey);
|
||||
|
||||
@@ -91,7 +75,7 @@
|
||||
}
|
||||
|
||||
public Collection<RecipeHolder<?>> getOrderedRecipes() {
|
||||
@@ -175,10 +205,31 @@
|
||||
@@ -171,10 +195,31 @@
|
||||
com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder);
|
||||
}
|
||||
|
||||
@@ -101,8 +85,8 @@
|
||||
+ this.byType = LinkedHashMultimap.create(builder.build());
|
||||
+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(MinecraftKey mcKey) {
|
||||
+ Iterator<RecipeHolder<?>> iter = byType.values().iterator();
|
||||
@@ -114,14 +98,14 @@
|
||||
+ }
|
||||
+
|
||||
+ return byName.remove(mcKey) != null;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ public void clearRecipes() {
|
||||
+ this.byType = LinkedHashMultimap.create();
|
||||
+ this.byName = Maps.newHashMap();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static <C extends IInventory, T extends IRecipe<C>> CraftingManager.a<C, T> createCheck(final Recipes<T> recipes) {
|
||||
return new CraftingManager.a<C, T>() {
|
||||
public static <I extends RecipeInput, T extends IRecipe<I>> CraftingManager.a<I, T> createCheck(final Recipes<T> recipes) {
|
||||
return new CraftingManager.a<I, T>() {
|
||||
@Nullable
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -72,4 +72,6 @@
|
||||
@@ -71,4 +71,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
@@ -5,6 +5,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class RecipeStonecutting extends RecipeSingleItem {
|
||||
|
||||
public RecipeStonecutting(String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -20,4 +28,16 @@
|
||||
@@ -18,4 +26,16 @@
|
||||
public ItemStack getToastSymbol() {
|
||||
return new ItemStack(Blocks.STONECUTTER);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -11,6 +11,14 @@
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -31,6 +39,68 @@
|
||||
@@ -30,6 +38,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
@@ -15,6 +15,13 @@
|
||||
@@ -13,6 +13,13 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -29,6 +36,22 @@
|
||||
@@ -27,6 +34,22 @@
|
||||
this.ingredients = nonnulllist;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
@@ -10,6 +10,14 @@
|
||||
@@ -9,6 +9,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -67,6 +75,17 @@
|
||||
@@ -64,6 +72,17 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -20,6 +20,13 @@
|
||||
@@ -19,6 +19,13 @@
|
||||
import net.minecraft.world.item.armortrim.TrimPatterns;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -100,6 +107,13 @@
|
||||
@@ -97,6 +104,13 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
--- a/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java
|
||||
+++ b/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java
|
||||
@@ -39,8 +39,11 @@
|
||||
IBlockData iblockdata2 = world.getBlockState(blockposition1);
|
||||
|
||||
if (iblockdata2 == BlockIceFrost.meltsInto() && iblockdata.canSurvive(world, blockposition1) && world.isUnobstructed(iblockdata, blockposition1, VoxelShapeCollision.empty())) {
|
||||
- world.setBlockAndUpdate(blockposition1, iblockdata);
|
||||
- world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, iblockdata, entityliving)) {
|
||||
+ world.scheduleTick(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
|
||||
+++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
|
||||
@@ -35,7 +35,7 @@
|
||||
if (this.targets.get() == TagsEntity.SENSITIVE_TO_BANE_OF_ARTHROPODS && i > 0 && entityliving1.getType().is((TagKey) this.targets.get())) {
|
||||
int j = 20 + entityliving.getRandom().nextInt(10 * i);
|
||||
|
||||
- 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
|
||||
@@ -34,7 +34,7 @@
|
||||
int j = Math.round(MathHelper.randomBetween(randomsource, this.minDuration.calculate(i), this.maxDuration.calculate(i)) * 20.0F);
|
||||
int k = Math.max(0, Math.round(MathHelper.randomBetween(randomsource, this.minAmplifier.calculate(i), this.maxAmplifier.calculate(i))));
|
||||
|
||||
- entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k));
|
||||
+ entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
|
||||
@@ -8,6 +8,10 @@
|
||||
import net.minecraft.world.item.enchantment.LevelBasedValue;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect {
|
||||
|
||||
public static final MapCodec<Ignite> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -18,7 +22,15 @@
|
||||
|
||||
@Override
|
||||
public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) {
|
||||
- entity.igniteForSeconds(this.duration.calculate(i));
|
||||
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
||||
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(enchantediteminuse.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(i));
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (combustEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ entity.igniteForSeconds(combustEvent.getDuration(), false);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
if ((Boolean) this.predicate.map((blockpredicate) -> {
|
||||
return blockpredicate.test(worldserver, blockposition);
|
||||
- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition, this.blockState.getState(entity.getRandom(), blockposition))) {
|
||||
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, this.blockState.getState(entity.getRandom(), blockposition), entity)) { // CraftBukkit - Call EntityBlockFormEvent
|
||||
this.triggerGameEvent.ifPresent((holder) -> {
|
||||
worldserver.gameEvent(entity, holder, blockposition);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
if (blockposition1.distToCenterSqr(vec3d.x(), (double) blockposition1.getY() + 0.5D, vec3d.z()) < (double) MathHelper.square(j) && (Boolean) this.predicate.map((blockpredicate) -> {
|
||||
return blockpredicate.test(worldserver, blockposition1);
|
||||
- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition1, this.blockState.getState(randomsource, blockposition1))) {
|
||||
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition1, this.blockState.getState(randomsource, blockposition1), entity)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker
|
||||
this.triggerGameEvent.ifPresent((holder) -> {
|
||||
worldserver.gameEvent(entity, holder, blockposition1);
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
|
||||
@@ -20,6 +20,12 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.Items;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record SummonEntityEffect(HolderSet<EntityTypes<?>> entityTypes, boolean joinTeam) implements EnchantmentEntityEffect {
|
||||
|
||||
public static final MapCodec<SummonEntityEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -34,7 +40,7 @@
|
||||
Optional<Holder<EntityTypes<?>>> optional = this.entityTypes().getRandomElement(worldserver.getRandom());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EnumMobSpawn.TRIGGERED);
|
||||
+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EnumMobSpawn.TRIGGERED, false, false); // CraftBukkit
|
||||
|
||||
if (entity1 != null) {
|
||||
if (entity1 instanceof EntityLightning) {
|
||||
@@ -46,6 +52,11 @@
|
||||
|
||||
entitylightning.setCause(entityplayer);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ worldserver.strikeLightning(entity1, (enchantediteminuse.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT);
|
||||
+ } else {
|
||||
+ worldserver.addFreshEntityWithPassengers(entity, CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (this.joinTeam && entity.getTeam() != null) {
|
||||
Reference in New Issue
Block a user