mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 13:21:24 +01:00
Add missing forceDrop toggles
This commit is contained in:
parent
a600754f0d
commit
29ce813416
@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
@@ -86,7 +86,9 @@
|
||||
simpleContainer.removeItemType(Items.WHEAT, m);
|
||||
ItemStack itemStack = simpleContainer.addItem(new ItemStack(Items.BREAD, l));
|
||||
if (!itemStack.isEmpty()) {
|
||||
+ villager.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
villager.spawnAtLocation(world, itemStack, 0.5F);
|
||||
+ villager.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,14 +548,14 @@
|
||||
@@ -533,7 +540,9 @@
|
||||
|
||||
if (world1 instanceof ServerLevel worldserver) {
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.dropFromGiftLootTable(worldserver, BuiltInLootTables.PANDA_SNEEZE, this::spawnAtLocation);
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,14 +550,14 @@
|
||||
|
||||
@Override
|
||||
protected void pickUpItem(ServerLevel world, ItemEntity itemEntity) {
|
||||
@ -39,7 +49,17 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -772,7 +779,7 @@
|
||||
@@ -657,7 +666,9 @@
|
||||
ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||
|
||||
if (!itemstack1.isEmpty() && !player.hasInfiniteMaterials()) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.spawnAtLocation(worldserver, itemstack1);
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1));
|
||||
@@ -772,7 +783,7 @@
|
||||
}
|
||||
|
||||
public static Panda.Gene byName(String name) {
|
||||
@ -48,7 +68,7 @@
|
||||
}
|
||||
|
||||
public static Panda.Gene getRandom(RandomSource random) {
|
||||
@@ -876,10 +883,10 @@
|
||||
@@ -876,10 +887,10 @@
|
||||
private final Panda panda;
|
||||
|
||||
public PandaAvoidGoal(Panda panda, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
||||
@ -62,7 +82,17 @@
|
||||
this.panda = panda;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1123,7 @@
|
||||
@@ -935,7 +946,9 @@
|
||||
ItemStack itemstack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ Panda.this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
Panda.this.spawnAtLocation(getServerLevel(Panda.this.level()), itemstack);
|
||||
+ Panda.this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
||||
int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10;
|
||||
|
||||
@@ -1116,7 +1129,7 @@
|
||||
@Override
|
||||
protected void alertOther(Mob mob, LivingEntity target) {
|
||||
if (mob instanceof Panda && mob.isAggressive()) {
|
||||
|
@ -13,3 +13,15 @@
|
||||
this.shear(worldserver, SoundSource.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
itemstack.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
@@ -139,9 +145,11 @@
|
||||
}
|
||||
|
||||
private void spawnShearedMushrooms(ServerLevel world, ItemStack shears) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.dropFromShearingLootTable(world, BuiltInLootTables.BOGGED_SHEAR, shears, (worldserver1, itemstack1) -> {
|
||||
this.spawnAtLocation(worldserver1, itemstack1, this.getBbHeight());
|
||||
});
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,7 +88,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,7 +400,7 @@
|
||||
@@ -300,9 +326,11 @@
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel world) {
|
||||
PiglinAi.cancelAdmiring(world, this);
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.inventory.removeAllItems().forEach((itemstack) -> {
|
||||
this.spawnAtLocation(world, itemstack);
|
||||
});
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
super.finishConversion(world);
|
||||
}
|
||||
|
||||
@@ -374,7 +402,7 @@
|
||||
}
|
||||
|
||||
protected void holdInOffHand(ItemStack stack) {
|
||||
@ -97,7 +109,7 @@
|
||||
this.setItemSlot(EquipmentSlot.OFFHAND, stack);
|
||||
this.setGuaranteedDrop(EquipmentSlot.OFFHAND);
|
||||
} else {
|
||||
@@ -401,8 +427,8 @@
|
||||
@@ -401,8 +429,8 @@
|
||||
return false;
|
||||
} else {
|
||||
TagKey<Item> tagkey = this.getPreferredWeaponType();
|
||||
@ -108,7 +120,7 @@
|
||||
|
||||
return flag && !flag1 ? true : (!flag && flag1 ? false : super.canReplaceCurrentItem(newStack, currentStack, slot));
|
||||
}
|
||||
@@ -431,7 +457,7 @@
|
||||
@@ -431,7 +459,7 @@
|
||||
|
||||
@Override
|
||||
protected SoundEvent getAmbientSound() {
|
||||
|
@ -83,7 +83,17 @@
|
||||
|
||||
if (!flag) {
|
||||
PiglinAi.putInInventory(piglin, itemstack);
|
||||
@@ -272,7 +284,7 @@
|
||||
@@ -261,7 +273,9 @@
|
||||
|
||||
private static void holdInOffhand(ServerLevel world, Piglin piglin, ItemStack stack) {
|
||||
if (PiglinAi.isHoldingItemInOffHand(piglin)) {
|
||||
+ piglin.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
piglin.spawnAtLocation(world, piglin.getItemInHand(InteractionHand.OFF_HAND));
|
||||
+ piglin.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
piglin.holdInOffHand(stack);
|
||||
@@ -272,7 +286,7 @@
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
@ -92,7 +102,7 @@
|
||||
} else {
|
||||
stack.setItem(itemstack);
|
||||
}
|
||||
@@ -287,9 +299,14 @@
|
||||
@@ -287,9 +301,14 @@
|
||||
boolean flag1;
|
||||
|
||||
if (piglin.isAdult()) {
|
||||
@ -109,7 +119,7 @@
|
||||
} else if (!flag1) {
|
||||
boolean flag2 = !piglin.equipItemIfPossible(world, itemstack).isEmpty();
|
||||
|
||||
@@ -302,7 +319,7 @@
|
||||
@@ -302,7 +321,7 @@
|
||||
if (!flag1) {
|
||||
ItemStack itemstack1 = piglin.getMainHandItem();
|
||||
|
||||
@ -118,7 +128,17 @@
|
||||
PiglinAi.putInInventory(piglin, itemstack1);
|
||||
} else {
|
||||
PiglinAi.throwItems(piglin, Collections.singletonList(itemstack1));
|
||||
@@ -379,14 +396,20 @@
|
||||
@@ -316,7 +335,9 @@
|
||||
|
||||
protected static void cancelAdmiring(ServerLevel world, Piglin piglin) {
|
||||
if (PiglinAi.isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) {
|
||||
+ piglin.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
piglin.spawnAtLocation(world, piglin.getOffhandItem());
|
||||
+ piglin.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@@ -379,7 +400,7 @@
|
||||
return false;
|
||||
} else if (PiglinAi.isAdmiringDisabled(piglin) && piglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) {
|
||||
return false;
|
||||
@ -127,20 +147,20 @@
|
||||
return PiglinAi.isNotHoldingLovedItemInOffHand(piglin);
|
||||
} else {
|
||||
boolean flag = piglin.canAddToInventory(stack);
|
||||
|
||||
return stack.is(Items.GOLD_NUGGET) ? flag : (PiglinAi.isFood(stack) ? !PiglinAi.hasEatenRecently(piglin) && flag : (!PiglinAi.isLovedItem(stack) ? piglin.canReplaceCurrentItem(stack) : PiglinAi.isNotHoldingLovedItemInOffHand(piglin) && flag));
|
||||
@@ -388,6 +409,12 @@
|
||||
}
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Added method to allow checking for custom payment items
|
||||
+ protected static boolean isLovedItem(ItemStack itemstack, Piglin piglin) {
|
||||
+ return PiglinAi.isLovedItem(itemstack) || (piglin.interestItems.contains(itemstack.getItem()) || piglin.allowedBarterItems.contains(itemstack.getItem()));
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
protected static boolean isLovedItem(ItemStack stack) {
|
||||
return stack.is(ItemTags.PIGLIN_LOVED);
|
||||
@@ -481,7 +504,7 @@
|
||||
}
|
||||
@@ -481,7 +508,7 @@
|
||||
}
|
||||
|
||||
protected static boolean canAdmire(Piglin piglin, ItemStack nearbyItems) {
|
||||
@ -149,21 +169,20 @@
|
||||
}
|
||||
|
||||
protected static void wasHurtBy(ServerLevel world, Piglin piglin, LivingEntity attacker) {
|
||||
@@ -733,7 +756,13 @@
|
||||
|
||||
private static boolean isAdmiringItem(Piglin entity) {
|
||||
@@ -735,6 +762,12 @@
|
||||
return entity.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Changes to allow custom payment for bartering
|
||||
+ private static boolean isBarterCurrency(ItemStack itemstack, Piglin piglin) {
|
||||
+ return PiglinAi.isBarterCurrency(itemstack) || piglin.allowedBarterItems.contains(itemstack.getItem());
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
private static boolean isBarterCurrency(ItemStack stack) {
|
||||
return stack.is(PiglinAi.BARTERING_ITEM);
|
||||
@@ -772,7 +801,7 @@
|
||||
}
|
||||
@@ -772,7 +805,7 @@
|
||||
}
|
||||
|
||||
private static boolean isNotHoldingLovedItemInOffHand(Piglin piglin) {
|
||||
|
@ -10,7 +10,15 @@
|
||||
|
||||
public abstract class Raider extends PatrollingMonster {
|
||||
|
||||
@@ -236,7 +239,7 @@
|
||||
@@ -230,13 +233,15 @@
|
||||
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
|
||||
this.spawnAtLocation(world, itemstack1);
|
||||
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
|
||||
}
|
||||
|
||||
this.onItemPickup(itemEntity);
|
||||
this.setItemSlot(enumitemslot, itemstack);
|
||||
this.take(itemEntity, itemstack.getCount());
|
||||
@ -19,7 +27,7 @@
|
||||
this.getCurrentRaid().setLeader(this.getWave(), this);
|
||||
this.setPatrolLeader(true);
|
||||
} else {
|
||||
@@ -290,7 +293,7 @@
|
||||
@@ -290,7 +295,7 @@
|
||||
@Nullable
|
||||
private ItemEntity pursuedBannerItemEntity;
|
||||
|
||||
@ -28,7 +36,7 @@
|
||||
this.mob = entityraider;
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
@@ -335,6 +338,7 @@
|
||||
@@ -335,6 +340,7 @@
|
||||
}
|
||||
|
||||
private boolean cannotPickUpBanner() {
|
||||
@ -36,7 +44,7 @@
|
||||
if (!this.mob.hasActiveRaid()) {
|
||||
return true;
|
||||
} else if (this.mob.getCurrentRaid().isOver()) {
|
||||
@@ -518,7 +522,7 @@
|
||||
@@ -518,7 +524,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +53,7 @@
|
||||
|
||||
private final Raider mob;
|
||||
private final float hostileRadiusSqr;
|
||||
@@ -547,7 +551,7 @@
|
||||
@@ -547,7 +553,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Raider entityraider = (Raider) iterator.next();
|
||||
|
||||
@ -54,7 +62,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -564,7 +568,7 @@
|
||||
@@ -564,7 +570,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Raider entityraider = (Raider) iterator.next();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user