mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
922
This commit is contained in:
parent
0785c29a37
commit
4eaa335676
@ -68,8 +68,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
if (user.fishing != null) {
|
||||
if (!world.isClientSide) {
|
||||
- i = user.fishing.retrieve(itemstack);
|
||||
+ i = user.fishing.retrieve(hand, itemstack); // Paper - Add hand parameter to PlayerFishEvent
|
||||
- int i = user.fishing.retrieve(itemstack);
|
||||
+ int i = user.fishing.retrieve(hand, itemstack); // Paper - Add hand parameter to PlayerFishEvent
|
||||
|
||||
itemstack.hurtAndBreak(i, user, LivingEntity.getSlotForHand(hand));
|
||||
}
|
||||
|
@ -4,19 +4,6 @@ Date: Mon, 11 Sep 2023 12:01:57 +1000
|
||||
Subject: [PATCH] Add slot sanity checks in container clicks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/component/DataComponentPatch.java b/src/main/java/net/minecraft/core/component/DataComponentPatch.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/component/DataComponentPatch.java
|
||||
+++ b/src/main/java/net/minecraft/core/component/DataComponentPatch.java
|
||||
@@ -0,0 +0,0 @@ public final class DataComponentPatch {
|
||||
if (i == 0 && j == 0) {
|
||||
return DataComponentPatch.EMPTY;
|
||||
} else {
|
||||
- Reference2ObjectMap<DataComponentType<?>, Optional<?>> reference2objectmap = new Reference2ObjectArrayMap(i + j);
|
||||
+ Reference2ObjectMap<DataComponentType<?>, Optional<?>> reference2objectmap = new Reference2ObjectArrayMap(Math.min(i + j, 256)); // Paper - sensible initial size limit
|
||||
|
||||
DataComponentType datacomponenttype;
|
||||
int k;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
this.nextContainerCounter();
|
||||
AbstractContainerMenu container = factory.createMenu(this.containerCounter, this.getInventory(), this);
|
||||
|
||||
@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
if (container == null && !cancelled) { // Let pre-cancelled events fall through
|
||||
// SPIGOT-5263 - close chest if cancelled
|
||||
if (factory instanceof Container) {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
this.containerMenu = container;
|
||||
@ -117,4 +117,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return com.mojang.datafixers.util.Pair.of(event.titleOverride(), container); // Paper - Add titleOverride to InventoryOpenEvent
|
||||
}
|
||||
|
||||
public static ItemStack callPreCraftEvent(Container matrix, Container resultInventory, ItemStack result, InventoryView lastCraftView, boolean isRepair) {
|
||||
public static ItemStack callPreCraftEvent(CraftingContainer matrix, Container resultInventory, ItemStack result, InventoryView lastCraftView, boolean isRepair) {
|
@ -16,9 +16,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
public ThrownTrident(Level world, LivingEntity owner, ItemStack stack) {
|
||||
super(EntityType.TRIDENT, owner, world, stack);
|
||||
super(EntityType.TRIDENT, owner, world, stack, (ItemStack) null);
|
||||
+ this.setBaseDamage(net.minecraft.world.item.TridentItem.BASE_DAMAGE); // Paper - Allow trident custom damage
|
||||
this.entityData.set(ThrownTrident.ID_LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack));
|
||||
this.entityData.set(ThrownTrident.ID_LOYALTY, this.getLoyaltyFromItem(stack));
|
||||
this.entityData.set(ThrownTrident.ID_FOIL, stack.hasFoil());
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ThrownTrident extends AbstractArrow {
|
||||
@ -27,6 +27,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
Entity entity = entityHitResult.getEntity();
|
||||
- float f = 8.0F;
|
||||
+ float f = (float) this.getBaseDamage(); // Paper - Allow trident custom damage
|
||||
|
||||
if (entity instanceof LivingEntity entityliving) {
|
||||
f += EnchantmentHelper.getDamageBonus(this.getPickupItemStackOrigin(), entityliving.getType());
|
||||
Entity entity1 = this.getOwner();
|
||||
DamageSource damagesource = this.damageSources().trident(this, (Entity) (entity1 == null ? this : entity1));
|
||||
Level world = this.level();
|
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||
@@ -0,0 +0,0 @@ public class ItemFrame extends HangingEntity {
|
||||
public static final int NUM_ROTATIONS = 8;
|
||||
private static final float HEIGHT = 0.75F;
|
||||
public float dropChance;
|
||||
public boolean fixed;
|
||||
+ public @Nullable MapId cachedMapId; // Paper - Perf: Cache map ids on item frames
|
@ -9,29 +9,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
|
||||
@@ -0,0 +0,0 @@ public class ExperienceOrb extends Entity {
|
||||
ItemStack itemstack = (ItemStack) entry.getValue();
|
||||
int j = Math.min(this.xpToDurability(amount), itemstack.getDamageValue());
|
||||
|
||||
if (optional.isPresent()) {
|
||||
ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack();
|
||||
- int j = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), itemstack, amount);
|
||||
- int k = Math.min(j, itemstack.getDamageValue());
|
||||
+ int j = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), itemstack, amount);; int xpTranslatedToDurability = j; // Paper - mending event - obfhelper
|
||||
+ int k = Math.min(j, itemstack.getDamageValue()); int durabilityToAddBack = k; // Paper - mending event - obfhelper
|
||||
// CraftBukkit start
|
||||
- org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j);
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j, this::durabilityToXp); // Paper - Expand PlayerItemMendEvent
|
||||
j = event.getRepairAmount();
|
||||
- org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), k);
|
||||
- k = event.getRepairAmount();
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, optional.get().inSlot(), durabilityToAddBack, d -> d * amount / xpTranslatedToDurability); // Paper - Expand PlayerItemMendEvent
|
||||
+ durabilityToAddBack = event.getRepairAmount(); // Paper - mending event - obfhelper
|
||||
if (event.isCancelled()) {
|
||||
return amount;
|
||||
@@ -0,0 +0,0 @@ public class ExperienceOrb extends Entity {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
itemstack.setDamageValue(itemstack.getDamageValue() - j);
|
||||
- int k = amount - this.durabilityToXp(j);
|
||||
+ int k = amount - event.getDurabilityToXpOperation().applyAsInt(j); // Paper - Expand PlayerItemMendEvent
|
||||
// this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls // Paper - the value field should not be mutated here because it doesn't take "count" into account
|
||||
+ // Paper start - Expand PlayerItemMendEvent
|
||||
+ if (j == 0 && amount == k) { // if repair amount is 0 and no xp was removed, don't do recursion; treat as cancelled
|
||||
+ return k;
|
||||
+ }
|
||||
+ // Paper end - Expand PlayerItemMendEvent
|
||||
- itemstack.setDamageValue(itemstack.getDamageValue() - k);
|
||||
+ itemstack.setDamageValue(itemstack.getDamageValue() - durabilityToAddBack); // Paper - mending event - obfhelper
|
||||
if (k > 0) {
|
||||
- int l = amount - k * amount / j;
|
||||
+ int l = amount - event.getDurabilityToXpOperation().applyAsInt(durabilityToAddBack); // Paper - mending event - obfhelper
|
||||
|
||||
return k > 0 ? this.repairPlayerItems(player, k) : 0;
|
||||
} else {
|
||||
if (l > 0) {
|
||||
// this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls // Paper - the value field should not be mutated here because it doesn't take "count" into account
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@ -41,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
int i = Math.min(orb.xpToDurability(amount), itemstack.getDamageValue());
|
||||
- org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i);
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i, orb::durabilityToXp); // Paper - Expand PlayerItemMendEvent
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.get().inSlot(), i, orb::durabilityToXp); // Paper - Expand PlayerItemMendEvent
|
||||
i = event.getRepairAmount();
|
||||
orb.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
||||
if (!event.isCancelled()) {
|
@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null");
|
||||
this.checkAttributeList();
|
||||
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {
|
||||
- Preconditions.checkArgument(!entry.getValue().getUniqueId().equals(modifier.getUniqueId()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier);
|
||||
+ Preconditions.checkArgument(!(entry.getValue().getUniqueId().equals(modifier.getUniqueId()) && entry.getKey() == attribute), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper
|
||||
- Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()), "Cannot register AttributeModifier. Modifier is already applied! %s", modifier);
|
||||
+ Preconditions.checkArgument(!entry.getValue().getKey().equals(modifier.getKey()) && entry.getKey() == attribute, "Cannot register AttributeModifier. Modifier is already applied! %s", modifier); // Paper - attribute modifiers with same namespaced key but on different attributes are fine
|
||||
}
|
||||
return this.attributeModifiers.put(attribute, modifier);
|
||||
}
|
@ -21,25 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(entityhuman, iblockdata1));
|
||||
itemstack.consume(1, entityhuman);
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
|
||||
if (tileentity instanceof JukeboxBlockEntity) {
|
||||
JukeboxBlockEntity tileentityjukebox = (JukeboxBlockEntity) tileentity;
|
||||
|
||||
- // There can only be one
|
||||
- ItemStack record = this.copy();
|
||||
- if (!record.isEmpty()) {
|
||||
- record.setCount(1);
|
||||
- }
|
||||
-
|
||||
- tileentityjukebox.setTheItem(record);
|
||||
+ tileentityjukebox.setTheItem(this.copy()); // Paper - Fix block place logic; sync this with record item, jukebox has now an inventory
|
||||
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition)));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
|
||||
// Use method to resend items in hands in case of client desync, because the item use got cancelled.
|
||||
// For example, when cancelling the leash event
|
||||
@ -16,21 +16,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public void resendItemInHands() {
|
||||
this.containerMenu.findSlot(this.getInventory(), this.getInventory().selected).ifPresent(s -> {
|
||||
this.containerSynchronizer.sendSlotChange(this.containerMenu, s, this.getMainHandItem());
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
if (itemstack.is(Items.LEAD) && this.canBeLeashed(player)) {
|
||||
// CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
if (CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) {
|
||||
- ((ServerPlayer) player).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item
|
||||
+ // ((ServerPlayer) player).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item // Paper - handled below
|
||||
((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
|
||||
+ player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cow.java b/src/main/java/net/minecraft/world/entity/animal/Cow.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Cow.java
|
@ -26,8 +26,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
entity.setDirection(hangingData.direction());
|
||||
@@ -0,0 +0,0 @@ public final class CraftEntityTypes {
|
||||
AABB bb = (ItemFrame.class.isAssignableFrom(clazz))
|
||||
? net.minecraft.world.entity.decoration.ItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height)
|
||||
: HangingEntity.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height);
|
||||
? net.minecraft.world.entity.decoration.ItemFrame.calculateBoundingBoxStatic(pos, CraftBlock.blockFaceToNotch(dir).getOpposite())
|
||||
: net.minecraft.world.entity.decoration.Painting.calculateBoundingBoxStatic(pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height);
|
||||
+ if (!spawnData.world.noCollision(bb)) continue; // Paper - add collision check
|
||||
List<net.minecraft.world.entity.Entity> list = spawnData.world().getEntities(null, bb);
|
||||
for (Iterator<net.minecraft.world.entity.Entity> it = list.iterator(); !taken && it.hasNext(); ) {
|
@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftEntityTypes {
|
||||
Vector direction = spawnData.location().getDirection().multiply(10);
|
||||
entity.assignPower(direction.getX(), direction.getY(), direction.getZ());
|
||||
Vector direction = spawnData.location().getDirection();
|
||||
entity.assignDirectionalMovement(new Vec3(direction.getX(), direction.getY(), direction.getZ()), 1.0);
|
||||
};
|
||||
+ private static final BiConsumer<SpawnData, net.minecraft.world.entity.Entity> ROT = (spawnData, entity) -> entity.setRot(spawnData.yaw(), spawnData.pitch()); // Paper
|
||||
private static final Map<Class<?>, EntityTypeData<?, ?>> CLASS_TYPE_DATA = new HashMap<>();
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
|
||||
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
||||
@ -25,11 +25,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack);
|
||||
+ this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
|
||||
break;
|
||||
case ARMOR:
|
||||
case HUMANOID_ARMOR:
|
||||
- this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack);
|
||||
+ this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
|
||||
break;
|
||||
case BODY:
|
||||
case ANIMAL_ARMOR:
|
||||
ItemStack itemstack1 = this.bodyArmorItem;
|
||||
|
||||
this.bodyArmorItem = stack;
|
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20);
|
||||
private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault();
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
||||
|
||||
+ // Paper start - Prevent causing expired keys from impacting new joins
|
@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool, boolean includeDrops, boolean dropExp) { // Paper - fix drops not preventing stats/food exhaustion
|
||||
+ super.playerDestroy(world, player, pos, state, blockEntity, tool, includeDrops, dropExp); // Paper - fix drops not preventing stats/food exhaustion
|
||||
if (!world.isClientSide && blockEntity instanceof BeehiveBlockEntity tileentitybeehive) {
|
||||
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) {
|
||||
if (!EnchantmentHelper.hasTag(tool, EnchantmentTags.PREVENTS_BEE_SPAWNS_WHEN_MINING)) {
|
||||
tileentitybeehive.emptyAllLivingFromHive(player, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftEntityTypes {
|
||||
entity.assignPower(direction.getX(), direction.getY(), direction.getZ());
|
||||
entity.assignDirectionalMovement(new Vec3(direction.getX(), direction.getY(), direction.getZ()), 1.0);
|
||||
};
|
||||
private static final BiConsumer<SpawnData, net.minecraft.world.entity.Entity> ROT = (spawnData, entity) -> entity.setRot(spawnData.yaw(), spawnData.pitch()); // Paper
|
||||
+ // Paper start - respect randomizeData
|
@ -12,7 +12,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
if (this.isRemoved()) {
|
||||
return;
|
||||
}
|
||||
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
if (!keepInventory) {
|
||||
for (ItemStack item : this.getInventory().getContents()) {
|
||||
if (!item.isEmpty() && !EnchantmentHelper.hasVanishingCurse(item)) {
|
||||
if (!item.isEmpty() && EnchantmentHelper.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
|
||||
- loot.add(CraftItemStack.asCraftMirror(item));
|
||||
+ loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event)
|
||||
}
|
||||
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
this.drops.clear(); // SPIGOT-5188: make sure to clear
|
||||
} // Paper - fix player loottables running when mob loot gamerule is false
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,9 +108,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
protected float appliedScale;
|
||||
// CraftBukkit start
|
||||
public int expToDrop;
|
||||
public boolean forceDrops;
|
||||
- public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ public ArrayList<DefaultDrop> drops = new ArrayList<>(); // Paper - Restore vanilla drops behavior
|
||||
public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
@ -122,11 +122,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
@Override
|
||||
protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) {
|
||||
super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops);
|
||||
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {
|
||||
super.dropCustomDeathLoot(world, source, causedByPlayer);
|
||||
- ItemEntity entityitem = this.spawnAtLocation((ItemLike) Items.NETHER_STAR);
|
||||
-
|
||||
+ ItemEntity entityitem = this.spawnAtLocation(new net.minecraft.world.item.ItemStack(Items.NETHER_STAR), 0, ItemEntity::setExtendedLifetime); // Paper - Restore vanilla drops behavior; spawnAtLocation returns null so modify the item entity with a consumer
|
||||
|
||||
if (entityitem != null) {
|
||||
- entityitem.setExtendedLifetime();
|
||||
+ entityitem.setExtendedLifetime(); // Paper - diff on change
|
||||
@ -143,7 +143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
|
||||
- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior
|
||||
return this.brokenByAnything(damageSource); // Paper
|
||||
return this.brokenByAnything(world, damageSource); // Paper
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
|
||||
@ -192,8 +192,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
// Paper end
|
||||
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
|
||||
CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource);
|
||||
- EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward());
|
||||
+ EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward()); // Paper - Restore vanilla drops behavior
|
||||
- EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()));
|
||||
+ EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(damageSource.getEntity())); // Paper - Restore vanilla drops behavior
|
||||
populateFields(victim, event); // Paper - make cancellable
|
||||
CraftWorld world = (CraftWorld) entity.getWorld();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -221,8 +221,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageSource damageSource, List<Entity.DefaultDrop> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure & Restore vanilla drops behavior
|
||||
CraftPlayer entity = victim.getBukkitEntity();
|
||||
CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource);
|
||||
- PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(), 0, deathMessage);
|
||||
+ PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(), 0, deathMessage); // Paper - Restore vanilla drops behavior
|
||||
- PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()), 0, deathMessage);
|
||||
+ PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(damageSource.getEntity()), 0, deathMessage); // Paper - Restore vanilla drops behavior
|
||||
event.setKeepInventory(keepInventory);
|
||||
event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel
|
||||
populateFields(victim, event); // Paper - make cancellable
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user