Update to Minecraft 1.19.3

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-12-08 03:00:00 +11:00
parent a13136ada2
commit 8b26bb8f3e
305 changed files with 3331 additions and 2864 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
@@ -44,6 +44,12 @@
@@ -43,6 +43,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -13,7 +13,7 @@
public class EntityCreeper extends EntityMonster implements PowerableMob {
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
@@ -219,9 +225,19 @@
@@ -218,9 +224,19 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
super.thunderHit(worldserver, entitylightning);
@@ -35,11 +35,11 @@
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
@@ -246,10 +262,18 @@
Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
if (!this.level.isClientSide) {
float f = this.isPowered() ? 2.0F : 1.0F;
- this.dead = true;
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, explosion_effect);
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
- this.discard();
- this.spawnLingeringCloud();
+ // CraftBukkit start
@@ -47,7 +47,7 @@
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.dead = true;
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.discard();
+ this.spawnLingeringCloud();
+ } else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
@@ -109,7 +109,17 @@
@@ -114,7 +114,17 @@
@Override
public void setTarget(@Nullable EntityLiving entityliving) {
@@ -19,7 +19,7 @@
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
@@ -124,6 +134,7 @@
@@ -129,6 +139,7 @@
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
@@ -27,7 +27,7 @@
}
@@ -474,9 +485,13 @@
@@ -490,9 +501,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
@@ -41,7 +41,7 @@
}
}
@@ -515,9 +530,13 @@
@@ -531,9 +546,13 @@
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityEvoker.java
+++ b/net/minecraft/world/entity/monster/EntityEvoker.java
@@ -191,7 +191,7 @@
entityvex.setOwner(EntityEvoker.this);
entityvex.setBoundOrigin(blockposition);
entityvex.setLimitedLife(20 * (30 + EntityEvoker.this.random.nextInt(90)));
- worldserver.addFreshEntityWithPassengers(entityvex);
+ worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason
@@ -192,7 +192,7 @@
entityvex.setOwner(EntityEvoker.this);
entityvex.setBoundOrigin(blockposition);
entityvex.setLimitedLife(20 * (30 + EntityEvoker.this.random.nextInt(90)));
- worldserver.addFreshEntityWithPassengers(entityvex);
+ worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java
+++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java
@@ -161,6 +161,11 @@
@@ -155,6 +155,11 @@
public void tick() {
--this.attackWarmupDelay;
if (this.attackWarmupDelay == 0) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityPigZombie.java
+++ b/net/minecraft/world/entity/monster/EntityPigZombie.java
@@ -145,7 +145,7 @@
@@ -154,7 +154,7 @@
}).filter((entitypigzombie) -> {
return !entitypigzombie.isAlliedTo((Entity) this.getTarget());
}).forEach((entitypigzombie) -> {
@@ -9,7 +9,7 @@
});
}
@@ -154,7 +154,7 @@
@@ -163,7 +163,7 @@
}
@Override
@@ -18,7 +18,7 @@
if (this.getTarget() == null && entityliving != null) {
this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random);
this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random);
@@ -164,12 +164,21 @@
@@ -173,12 +173,21 @@
this.setLastHurtByPlayer((EntityHuman) entityliving);
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntityShulker.java
+++ b/net/minecraft/world/entity/monster/EntityShulker.java
@@ -57,6 +57,12 @@
import net.minecraft.world.phys.AxisAlignedBB;
@@ -59,6 +59,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import net.minecraft.server.level.WorldServer;
@@ -10,10 +10,10 @@
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
public class EntityShulker extends EntityGolem implements IMonster {
public class EntityShulker extends EntityGolem implements VariantHolder<Optional<EnumColor>>, IMonster {
private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
@@ -405,6 +411,16 @@
@@ -407,6 +413,16 @@
EnumDirection enumdirection = this.findAttachableSurface(blockposition1);
if (enumdirection != null) {
@@ -30,12 +30,12 @@
this.unRide();
this.setAttachFace(enumdirection);
this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F);
@@ -478,7 +494,7 @@
@@ -477,7 +493,7 @@
if (entityshulker != null) {
entityshulker.setVariant(this.getVariant());
entityshulker.moveTo(vec3d);
- this.level.addFreshEntity(entityshulker);
+ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
}
entityshulker.moveTo(vec3d);
- this.level.addFreshEntity(entityshulker);
+ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntitySkeleton.java
+++ b/net/minecraft/world/entity/monster/EntitySkeleton.java
@@ -86,7 +86,7 @@
@@ -90,7 +90,7 @@
}
protected void doFreezeConversion() {

View File

@@ -15,7 +15,7 @@
public class EntitySlime extends EntityInsentient implements IMonster {
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
@@ -184,7 +192,7 @@
@@ -185,7 +193,7 @@
@Override
public EntityTypes<? extends EntitySlime> getType() {
@@ -24,7 +24,7 @@
}
@Override
@@ -198,6 +206,19 @@
@@ -199,6 +207,19 @@
int j = i / 2;
int k = 2 + this.random.nextInt(3);
@@ -44,14 +44,14 @@
for (int l = 0; l < k; ++l) {
float f1 = ((float) (l % 2) - 0.5F) * f;
float f2 = ((float) (l / 2) - 0.5F) * f;
@@ -212,8 +233,18 @@
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSize(j, true);
entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);
- this.level.addFreshEntity(entityslime);
+ slimes.add(entityslime); // CraftBukkit
+ }
+
@@ -214,9 +235,18 @@
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSize(j, true);
entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);
- this.level.addFreshEntity(entityslime);
+ slimes.add(entityslime); // CraftBukkit
}
}
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
+ super.remove(entity_removalreason);
@@ -59,7 +59,7 @@
+ }
+ for (EntityLiving living : slimes) {
+ this.level.addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
}
+ }
+ // CraftBukkit end
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntitySpider.java
+++ b/net/minecraft/world/entity/monster/EntitySpider.java
@@ -177,7 +177,7 @@
@@ -179,7 +179,7 @@
MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).effect;
if (mobeffectlist != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityVex.java
+++ b/net/minecraft/world/entity/monster/EntityVex.java
@@ -373,7 +373,7 @@
@@ -386,7 +386,7 @@
@Override
public void start() {

View File

@@ -16,7 +16,7 @@
public class EntityZombie extends EntityMonster {
private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
@@ -85,6 +94,7 @@
@@ -86,6 +95,7 @@
private boolean canBreakDoors;
private int inWaterTime;
public int conversionTime;
@@ -24,7 +24,7 @@
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
super(entitytypes, world);
@@ -201,7 +211,10 @@
@@ -202,7 +212,10 @@
public void tick() {
if (!this.level.isClientSide && this.isAlive() && !this.isNoAi()) {
if (this.isUnderWaterConverting()) {
@@ -36,7 +36,7 @@
if (this.conversionTime < 0) {
this.doUnderWaterConversion();
}
@@ -218,6 +231,7 @@
@@ -219,6 +232,7 @@
}
super.tick();
@@ -44,7 +44,7 @@
}
@Override
@@ -250,6 +264,7 @@
@@ -251,6 +265,7 @@
}
public void startUnderWaterConversion(int i) {
@@ -52,7 +52,7 @@
this.conversionTime = i;
this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true);
}
@@ -263,11 +278,15 @@
@@ -264,11 +279,15 @@
}
protected void convertToZombieType(EntityTypes<? extends EntityZombie> entitytypes) {
@@ -69,7 +69,7 @@
}
}
@@ -307,9 +326,9 @@
@@ -308,9 +327,9 @@
if (SpawnerCreature.isSpawnPositionOk(entitypositiontypes_surface, this.level, blockposition, entitytypes) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) {
entityzombie.setPos((double) i1, (double) j1, (double) k1);
if (!this.level.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) {
@@ -81,7 +81,7 @@
this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
break;
@@ -330,7 +349,14 @@
@@ -331,7 +350,14 @@
float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) {
@@ -97,49 +97,54 @@
}
}
@@ -412,21 +438,30 @@
@@ -413,8 +439,17 @@
if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
return flag;
}
EntityVillager entityvillager = (EntityVillager) entityliving;
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
+ // CraftBukkit start
+ flag = zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
+ }
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
+ return flag;
+ }
+
+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) {
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason);
+ if (entityzombievillager != null) {
+ {
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason);
+ // CraftBukkit end
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE).getValue());
entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag());
entityzombievillager.setVillagerXp(entityvillager.getVillagerXp());
- if (!this.isSilent()) {
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
+ // CraftBukkit start
+ if (!silent) {
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
if (entityzombievillager != null) {
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
@@ -422,15 +457,17 @@
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag());
entityzombievillager.setVillagerXp(entityvillager.getVillagerXp());
- if (!this.isSilent()) {
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
+ // CraftBukkit start
+ if (!silent) {
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
}
- flag = false;
+ // flag = false;
}
-
- flag = false;
+ // CraftBukkit end
}
- }
- return flag;
+ return entityzombievillager; // CraftBukkit
+ return entityzombievillager;
+ }
+ // CraftBukkit end
}
@Override
@@ -478,7 +513,7 @@
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);
- worldaccess.addFreshEntity(entitychicken1);
+ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
@@ -483,7 +520,7 @@
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);
- worldaccess.addFreshEntity(entitychicken1);
+ worldaccess.addFreshEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
}
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
@@ -54,6 +54,18 @@
@@ -56,6 +56,18 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -8,7 +8,7 @@
+import java.util.stream.Collectors;
+import java.util.HashSet;
+import java.util.Set;
+import net.minecraft.core.IRegistry;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+import net.minecraft.nbt.NBTBase;
@@ -19,10 +19,10 @@
public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier {
private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN);
@@ -74,6 +86,10 @@
@@ -76,6 +88,10 @@
public boolean cannotHunt;
protected static final ImmutableList<SensorType<? extends Sensor<? super EntityPiglin>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR);
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.WALK_TARGET, new MemoryModuleType[]{MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT});
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT});
+ // CraftBukkit start - Custom bartering and interest list
+ public Set<Item> allowedBarterItems = new HashSet<>();
+ public Set<Item> interestItems = new HashSet<>();
@@ -30,33 +30,33 @@
public EntityPiglin(EntityTypes<? extends EntityPiglinAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -92,6 +108,14 @@
@@ -94,6 +110,14 @@
}
nbttagcompound.put("Inventory", this.inventory.createTag());
this.writeInventoryToTag(nbttagcompound);
+ // CraftBukkit start
+ NBTTagList barterList = new NBTTagList();
+ allowedBarterItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add);
+ allowedBarterItems.stream().map(BuiltInRegistries.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(barterList::add);
+ nbttagcompound.put("Bukkit.BarterList", barterList);
+ NBTTagList interestList = new NBTTagList();
+ interestItems.stream().map(IRegistry.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add);
+ interestItems.stream().map(BuiltInRegistries.ITEM::getKey).map(MinecraftKey::toString).map(NBTTagString::valueOf).forEach(interestList::add);
+ nbttagcompound.put("Bukkit.InterestList", interestList);
+ // CraftBukkit end
}
@Override
@@ -100,6 +124,10 @@
@@ -102,6 +126,10 @@
this.setBaby(nbttagcompound.getBoolean("IsBaby"));
this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt"));
this.inventory.fromTag(nbttagcompound.getList("Inventory", 10));
this.readInventoryFromTag(nbttagcompound);
+ // CraftBukkit start
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(IRegistry.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ // CraftBukkit end
}
@VisibleForDebug
@@ -206,7 +234,7 @@
@@ -223,7 +251,7 @@
@Override
public BehaviorController<EntityPiglin> getBrain() {
@@ -65,7 +65,7 @@
}
@Override
@@ -349,7 +377,7 @@
@@ -368,7 +396,7 @@
}
protected void holdInOffHand(ItemStack itemstack) {
@@ -74,7 +74,7 @@
this.setItemSlot(EnumItemSlot.OFFHAND, itemstack);
this.setGuaranteedDrop(EnumItemSlot.OFFHAND);
} else {
@@ -375,8 +403,8 @@
@@ -394,8 +422,8 @@
if (EnchantmentManager.hasBindingCurse(itemstack1)) {
return false;
} else {
@@ -85,7 +85,7 @@
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1)));
}
@@ -405,7 +433,7 @@
@@ -424,7 +452,7 @@
@Override
protected SoundEffect getAmbientSound() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
@@ -100,7 +100,7 @@
@@ -108,7 +108,7 @@
}
protected void finishConversion(WorldServer worldserver) {
@@ -9,7 +9,7 @@
if (entitypigzombie != null) {
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
@@ -117,7 +117,7 @@
@@ -125,7 +125,7 @@
@Nullable
@Override
public EntityLiving getTarget() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java
@@ -71,6 +71,13 @@
@@ -74,6 +74,13 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.Vec3D;
@@ -14,7 +14,26 @@
public class PiglinAI {
public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8;
@@ -186,13 +193,13 @@
@@ -164,7 +171,8 @@
}
private static void initRideHoglinActivity(BehaviorController<EntityPiglin> behaviorcontroller) {
- behaviorcontroller.addActivityAndRemoveMemoryWhenStopped(Activity.RIDE, 10, ImmutableList.of(BehaviorStartRiding.create(0.8F), BehaviorLookTarget.create(PiglinAI::isPlayerHoldingLovedItem, 8.0F), BehaviorBuilder.sequence(BehaviorBuilder.triggerIf(Entity::isPassenger), TriggerGate.triggerOneShuffled(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(BehaviorBuilder.triggerIf((entitypiglin) -> {
+ // CraftBukkit - decompile error
+ behaviorcontroller.addActivityAndRemoveMemoryWhenStopped(Activity.RIDE, 10, ImmutableList.of(BehaviorStartRiding.create(0.8F), BehaviorLookTarget.create(PiglinAI::isPlayerHoldingLovedItem, 8.0F), BehaviorBuilder.sequence(BehaviorBuilder.triggerIf(Entity::isPassenger), TriggerGate.triggerOneShuffled(ImmutableList.<Pair<? extends net.minecraft.world.entity.ai.behavior.declarative.Trigger<? super EntityLiving>, Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(BehaviorBuilder.triggerIf((entitypiglin) -> {
return true;
}), 1)).build())), BehaviorStopRiding.create(8, PiglinAI::wantsToStopRiding)), MemoryModuleType.RIDE_TARGET);
}
@@ -174,7 +182,7 @@
}
private static BehaviorGateSingle<EntityLiving> createIdleLookBehaviors() {
- return new BehaviorGateSingle<>(ImmutableList.builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build());
+ return new BehaviorGateSingle<>(ImmutableList.<Pair<? extends BehaviorControl<? super EntityLiving>, Integer>>builder().addAll(createLookBehaviors()).add(Pair.of(new BehaviorNop(30, 60), 1)).build()); // CraftBukkit - decompile error
}
private static BehaviorGateSingle<EntityPiglin> createIdleMovementBehaviors() {
@@ -195,13 +203,13 @@
protected static void updateActivity(EntityPiglin entitypiglin) {
BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBrain();
@@ -31,7 +50,7 @@
Objects.requireNonNull(entitypiglin);
optional.ifPresent(entitypiglin::playSoundEvent);
@@ -224,23 +231,27 @@
@@ -233,23 +241,27 @@
stopWalking(entitypiglin);
ItemStack itemstack;
@@ -58,12 +77,12 @@
} else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) {
eat(entitypiglin);
} else {
- boolean flag = entitypiglin.equipItemIfPossible(itemstack);
+ boolean flag = entitypiglin.equipItemIfPossible(itemstack, entityitem); // CraftBukkit
- boolean flag = !entitypiglin.equipItemIfPossible(itemstack).equals(ItemStack.EMPTY);
+ boolean flag = !entitypiglin.equipItemIfPossible(itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit
if (!flag) {
putInInventory(entitypiglin, itemstack);
@@ -276,9 +287,14 @@
@@ -285,9 +297,14 @@
boolean flag1;
if (entitypiglin.isAdult()) {
@@ -78,9 +97,9 @@
+ }
+ // CraftBukkit end
} else if (!flag1) {
boolean flag2 = entitypiglin.equipItemIfPossible(itemstack);
boolean flag2 = !entitypiglin.equipItemIfPossible(itemstack).isEmpty();
@@ -291,7 +307,7 @@
@@ -300,7 +317,7 @@
if (!flag1) {
ItemStack itemstack1 = entitypiglin.getMainHandItem();
@@ -89,7 +108,7 @@
putInInventory(entitypiglin, itemstack1);
} else {
throwItems(entitypiglin, Collections.singletonList(itemstack1));
@@ -368,7 +384,7 @@
@@ -377,7 +394,7 @@
return false;
} else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) {
return false;
@@ -98,7 +117,7 @@
return isNotHoldingLovedItemInOffHand(entitypiglin);
} else {
boolean flag = entitypiglin.canAddToInventory(itemstack);
@@ -377,6 +393,12 @@
@@ -386,6 +403,12 @@
}
}
@@ -111,7 +130,7 @@
protected static boolean isLovedItem(ItemStack itemstack) {
return itemstack.is(TagsItem.PIGLIN_LOVED);
}
@@ -472,7 +494,7 @@
@@ -481,7 +504,7 @@
}
protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) {
@@ -120,7 +139,7 @@
}
protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) {
@@ -739,6 +761,12 @@
@@ -738,6 +761,12 @@
return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM);
}
@@ -133,7 +152,7 @@
private static boolean isBarterCurrency(ItemStack itemstack) {
return itemstack.is(PiglinAI.BARTERING_ITEM);
}
@@ -776,7 +804,7 @@
@@ -775,7 +804,7 @@
}
private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) {

View File

@@ -61,3 +61,12 @@
}
@Override
@@ -560,7 +560,7 @@
public void setAttackTarget(EntityLiving entityliving) {
this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET);
- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving);
+ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error
this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
SonicBoom.setCooldown(this, 200);
}