60/103 minecraft source files applied

This commit is contained in:
granny
2026-03-08 15:36:53 -07:00
parent c0cf991b1c
commit 5eb960544c
300 changed files with 1473 additions and 2406 deletions

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -380,7 +_,7 @@
private final Set<String> tags = new io.papermc.paper.util.SizeLimitedSet<>(new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(), MAX_ENTITY_TAG_COUNT); // Paper - fully limit tag size - replace set impl
private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0};
private long pistonDeltasGameTime;
- protected EntityDimensions dimensions;
+ private EntityDimensions dimensions;
private float eyeHeight;
public boolean isInPowderSnow;
public boolean wasInPowderSnow;

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/EntitySelector.java
+++ b/net/minecraft/world/entity/EntitySelector.java
@@ -28,6 +_,8 @@
return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks;
};
// Paper end - Ability to control player's insomnia and phantoms
+ public static Predicate<Player> notAfk = (player) -> !player.isAfk(); // Purpur - AFK API
+
// Paper start - Affects Spawning API
public static final Predicate<Entity> PLAYER_AFFECTS_SPAWNING = (entity) -> {
return !entity.isSpectator() && entity.isAlive() && entity instanceof Player player && player.affectsSpawning;

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/EntityType.java
+++ b/net/minecraft/world/entity/EntityType.java
@@ -1221,7 +_,7 @@
private final String descriptionId;
private @Nullable Component description;
private final Optional<ResourceKey<LootTable>> lootTable;
- public EntityDimensions dimensions;
+ private final EntityDimensions dimensions;
private final float spawnDimensionsScale;
private final FeatureFlagSet requiredFeatures;
private final boolean allowedInPeaceful;

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3852,7 +_,7 @@
}
}
- public boolean canGlide() {
+ protected boolean canGlide() {
if (!this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) {
for (EquipmentSlot slot : EquipmentSlot.VALUES) {
if (canGlideUsing(this.getItemBySlot(slot), slot)) {

View File

@@ -0,0 +1,18 @@
--- a/net/minecraft/world/entity/ai/goal/LlamaFollowCaravanGoal.java
+++ b/net/minecraft/world/entity/ai/goal/LlamaFollowCaravanGoal.java
@@ -22,6 +_,7 @@
@Override
public boolean canUse() {
+ if (!this.llama.level().purpurConfig.llamaJoinCaravans || !this.llama.shouldJoinCaravan) return false; // Purpur - Llama API // Purpur - Config to disable Llama caravans
if (!this.llama.isLeashed() && !this.llama.inCaravan()) {
List<Entity> llamas = this.llama
.level()
@@ -70,6 +_,7 @@
@Override
public boolean canContinueToUse() {
+ if (!this.llama.shouldJoinCaravan) return false; // Purpur - Llama API
if (this.llama.inCaravan() && this.llama.getCaravanHead().isAlive() && this.firstIsLeashed(this.llama, 0)) {
double distSqr = this.llama.distanceToSqr(this.llama.getCaravanHead());
if (distSqr > 676.0) {

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java
+++ b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java
@@ -116,9 +_,9 @@
}
this.mob.lookAt(target, 30.0F, 30.0F);
- } else {
+ } //else { // Purpur - MC-121706 - Fix mobs not looking up and down when strafing
this.mob.getLookControl().setLookAt(target, 30.0F, 30.0F);
- }
+ //} // Purpur - MC-121706 - Fix mobs not looking up and down when strafing
if (this.mob.isUsingItem()) {
if (!hasLineOfSight && this.seeTime < -60) {

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
+++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
@@ -59,7 +_,7 @@
if (passenger instanceof Player player) {
int temper = this.horse.getTemper();
int maxTemper = this.horse.getMaxTemper();
- if (maxTemper > 0 && this.horse.getRandom().nextInt(maxTemper) < temper && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent
+ if (((this.horse.level().purpurConfig.alwaysTameInCreative && player.hasInfiniteMaterials()) || (maxTemper > 0 && this.horse.getRandom().nextInt(maxTemper) < temper)) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent // Purpur - Config to always tame in Creative
this.horse.tameWithName(player);
return;
}

View File

@@ -0,0 +1,13 @@
--- a/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
+++ b/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
@@ -63,6 +_,10 @@
return false;
} else if (this.selector != null && !this.selector.test(target, level)) {
return false;
+ // Purpur start - AFK API
+ } else if (!level.purpurConfig.idleTimeoutTargetPlayer && target instanceof net.minecraft.server.level.ServerPlayer player && player.isAfk()) {
+ return false;
+ // Purpur end - AFK API
} else {
if (targeter == null) {
if (this.isCombat && (!target.canBeSeenAsEnemy() || level.getDifficulty() == Difficulty.PEACEFUL)) {

View File

@@ -0,0 +1,16 @@
--- a/net/minecraft/world/entity/animal/cow/MushroomCow.java
+++ b/net/minecraft/world/entity/animal/cow/MushroomCow.java
@@ -199,6 +_,13 @@
level.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, soundSource, 1.0F, 1.0F);
this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), cow -> {
level.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
+ // Purpur start - Fix cow rotation when shearing mooshroom
+ cow.copyPosition(this);
+ cow.yBodyRot = this.yBodyRot;
+ cow.setYHeadRot(this.getYHeadRot());
+ cow.yRotO = this.yRotO;
+ cow.xRotO = this.xRotO;
+ // Purpur end - Fix cow rotation when shearing mooshroom
// Paper start - custom shear drops; moved drop generation to separate method
drops.forEach(drop -> {
this.spawnAtLocation(level, new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), drop));

View File

@@ -0,0 +1,52 @@
--- a/net/minecraft/world/entity/animal/fox/Fox.java
+++ b/net/minecraft/world/entity/animal/fox/Fox.java
@@ -364,6 +_,11 @@
}
private void setTargetGoals() {
+ // Purpur start - Tulips change fox type - do not add duplicate goals
+ this.targetSelector.removeGoal(this.landTargetGoal);
+ this.targetSelector.removeGoal(this.turtleEggTargetGoal);
+ this.targetSelector.removeGoal(this.fishTargetGoal);
+ // Purpur end - Tulips change fox type
if (this.getVariant() == Fox.Variant.RED) {
this.targetSelector.addGoal(4, this.landTargetGoal);
this.targetSelector.addGoal(4, this.turtleEggTargetGoal);
@@ -391,6 +_,7 @@
public void setVariant(final Fox.Variant variant) {
this.entityData.set(DATA_TYPE_ID, variant.getId());
+ this.setTargetGoals(); // Purpur - Tulips change fox type - fix API bug not updating pathfinders on type change
}
@Override
@@ -716,6 +_,29 @@
return slot == EquipmentSlot.MAINHAND;
}
// Paper end
+
+ // Purpur start - Tulips change fox type
+ @Override
+ public net.minecraft.world.InteractionResult mobInteract(Player player, net.minecraft.world.InteractionHand hand) {
+ if (level().purpurConfig.foxTypeChangesWithTulips) {
+ ItemStack itemstack = player.getItemInHand(hand);
+ if (getVariant() == Variant.RED && itemstack.getItem() == Items.WHITE_TULIP) {
+ setVariant(Variant.SNOW);
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return net.minecraft.world.InteractionResult.SUCCESS;
+ } else if (getVariant() == Variant.SNOW && itemstack.getItem() == Items.ORANGE_TULIP) {
+ setVariant(Variant.RED);
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return net.minecraft.world.InteractionResult.SUCCESS;
+ }
+ }
+ return super.mobInteract(player, hand);
+ }
+ // Purpur end - Tulips change fox type
@Override
// Paper start - Cancellable death event

View File

@@ -0,0 +1,10 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -363,6 +_,7 @@
// Paper start - Goat ram API
public void ram(net.minecraft.world.entity.LivingEntity entity) {
+ if(!new org.purpurmc.purpur.event.entity.GoatRamEntityEvent((org.bukkit.entity.Goat) getBukkitEntity(), entity.getBukkitLivingEntity()).callEvent()) return; // Purpur - Added goat ram event
Brain<Goat> brain = this.getBrain();
brain.setMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.RAM_TARGET, entity.position());
brain.eraseMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.RAM_COOLDOWN_TICKS);

View File

@@ -0,0 +1,44 @@
--- a/net/minecraft/world/entity/animal/golem/CopperGolem.java
+++ b/net/minecraft/world/entity/animal/golem/CopperGolem.java
@@ -87,6 +_,7 @@
private final AnimationState interactionDropItemAnimationState = new AnimationState();
private final AnimationState interactionDropNoItemAnimationState = new AnimationState();
public static final EquipmentSlot EQUIPMENT_SLOT_ANTENNA = EquipmentSlot.SADDLE;
+ @Nullable private UUID summoner; // Purpur - Summoner API
public CopperGolem(final EntityType<? extends AbstractGolem> type, final Level level) {
super(type, level);
@@ -100,6 +_,17 @@
this.getBrain().setMemory(MemoryModuleType.TRANSPORT_ITEMS_COOLDOWN_TICKS, this.getRandom().nextInt(60, 100));
}
+ // Purpur start - Summoner API
+ @Nullable
+ public UUID getSummoner() {
+ return summoner;
+ }
+
+ public void setSummoner(@Nullable UUID summoner) {
+ this.summoner = summoner;
+ }
+ // Purpur end - Summoner API
+
public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.2F).add(Attributes.STEP_HEIGHT, 1.0).add(Attributes.MAX_HEALTH, 12.0);
}
@@ -170,6 +_,7 @@
super.addAdditionalSaveData(output);
output.putLong("next_weather_age", this.nextWeatheringTick);
output.store("weather_state", WeatheringCopper.WeatherState.CODEC, this.getWeatherState());
+ output.storeNullable("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC, getSummoner()); // Purpur - Summoner API
}
@Override
@@ -177,6 +_,7 @@
super.readAdditionalSaveData(input);
this.nextWeatheringTick = input.getLongOr("next_weather_age", -1L);
this.setWeatherState(input.read("weather_state", WeatheringCopper.WeatherState.CODEC).orElse(WeatheringCopper.WeatherState.UNAFFECTED));
+ this.setSummoner(input.read("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC).orElse(null)); // Purpur - Summoner API
}
@Override

View File

@@ -0,0 +1,61 @@
--- a/net/minecraft/world/entity/animal/golem/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/golem/SnowGolem.java
@@ -46,15 +_,26 @@
private static final EntityDataAccessor<Byte> DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE);
private static final byte PUMPKIN_FLAG = 16;
private static final boolean DEFAULT_PUMPKIN = true;
+ private java.util.@Nullable UUID summoner; // Purpur - Summoner API
public SnowGolem(final EntityType<? extends SnowGolem> type, final Level level) {
super(type, level);
}
+ // Purpur start - Summoner API
+ public java.util.@Nullable UUID getSummoner() {
+ return summoner;
+ }
+
+ public void setSummoner(java.util.@Nullable UUID summoner) {
+ this.summoner = summoner;
+ }
+ // Purpur end - Summoner API
+
@Override
protected void registerGoals() {
- this.goalSelector.addGoal(1, new RangedAttackGoal(this, 1.25, 20, 10.0F));
- this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0, 1.0000001E-5F));
+ this.goalSelector.addGoal(1, new RangedAttackGoal(this, level().purpurConfig.snowGolemAttackDistance, level().purpurConfig.snowGolemSnowBallMin, level().purpurConfig.snowGolemSnowBallMax, level().purpurConfig.snowGolemSnowBallModifier)); // Purpur - Snow Golem rate of fire config
+ this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0D, 1.0000001E-5F));
this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(4, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, (target, level) -> target instanceof Enemy));
@@ -74,12 +_,14 @@
protected void addAdditionalSaveData(final ValueOutput output) {
super.addAdditionalSaveData(output);
output.putBoolean("Pumpkin", this.hasPumpkin());
+ output.storeNullable("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC, getSummoner()); // Purpur - Summoner API
}
@Override
protected void readAdditionalSaveData(final ValueInput input) {
super.readAdditionalSaveData(input);
this.setPumpkin(input.getBooleanOr("Pumpkin", true));
+ this.setSummoner(input.read("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC).orElse(null)); // Purpur - Summoner API
}
@Override
@@ -156,6 +_,14 @@
}
return InteractionResult.SUCCESS;
+ // Purpur start - Snowman drop and put back pumpkin
+ } else if (level().purpurConfig.snowGolemPutPumpkinBack && !hasPumpkin() && itemInHand.getItem() == Blocks.CARVED_PUMPKIN.asItem()) {
+ setPumpkin(true);
+ if (!player.getAbilities().instabuild) {
+ itemInHand.shrink(1);
+ }
+ return InteractionResult.SUCCESS;
+ // Purpur end - Snowman drop and put back pumpkin
} else {
return InteractionResult.PASS;
}

View File

@@ -0,0 +1,16 @@
--- a/net/minecraft/world/entity/animal/squid/GlowSquid.java
+++ b/net/minecraft/world/entity/animal/squid/GlowSquid.java
@@ -30,6 +_,13 @@
super(type, level);
}
+ // Purpur start - Flying squids! Oh my!
+ @Override
+ public boolean canFly() {
+ return this.level().purpurConfig.glowSquidsCanFly;
+ }
+ // Purpur end - Flying squids! Oh my!
+
@Override
protected ParticleOptions getInkParticle() {
return ParticleTypes.GLOW_SQUID_INK;

View File

@@ -0,0 +1,43 @@
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -92,10 +_,13 @@
public boolean canTickSetByAPI = false;
private boolean noTickEquipmentDirty = false;
// Paper end - Allow ArmorStands not to tick
+ public boolean canMovementTick = true; // Purpur - Movement options for armor stands
public ArmorStand(final EntityType<? extends ArmorStand> type, final Level level) {
super(type, level);
if (level != null) this.canTick = level.paperConfig().entities.armorStands.tick; // Paper - Allow ArmorStands not to tick
+ if (level != null) this.canMovementTick = level.purpurConfig.armorstandMovement; // Purpur - Movement options for armor stands
+ this.setShowArms(level != null && level.purpurConfig.armorstandPlaceWithArms); // Purpur - Config to show Armor Stand arms on spawn
}
public ArmorStand(final Level level, final double x, final double y, final double z) {
@@ -521,6 +_,7 @@
// Paper start - Allow ArmorStands not to tick
@Override
public void tick() {
+ maxUpStep = level().purpurConfig.armorstandStepHeight; // Purpur - Add option to set armorstand step height
if (!this.canTick) {
if (this.noTickEquipmentDirty) {
this.noTickEquipmentDirty = false;
@@ -807,4 +_,18 @@
}
}
// Paper end
+
+ // Purpur start - Movement options for armor stands
+ @Override
+ public void updateInWaterStateAndDoWaterCurrentPushing() {
+ if (this.level().purpurConfig.armorstandWaterMovement &&
+ (this.level().purpurConfig.armorstandWaterFence || !(level().getBlockState(blockPosition().below()).getBlock() instanceof net.minecraft.world.level.block.FenceBlock)))
+ super.updateInWaterStateAndDoWaterCurrentPushing();
+ }
+
+ @Override
+ public void aiStep() {
+ if (this.canMovementTick && this.canMove) super.aiStep();
+ }
+ // Purpur end - Movement options for armor stands
}

View File

@@ -0,0 +1,35 @@
--- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -237,4 +_,32 @@
return !this.level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
}
// Paper end - Option to prevent TNT from moving in water
+
+ // Purpur start - Shears can defuse TNT
+ @Override
+ public net.minecraft.world.InteractionResult interact(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) {
+ Level world = this.level();
+
+ if (world instanceof ServerLevel serverWorld && level().purpurConfig.shearsCanDefuseTnt) {
+ final net.minecraft.world.item.ItemStack inHand = player.getItemInHand(hand);
+
+ if (!inHand.is(net.minecraft.world.item.Items.SHEARS) || !player.getBukkitEntity().hasPermission("purpur.tnt.defuse") ||
+ serverWorld.random.nextFloat() > serverWorld.purpurConfig.shearsCanDefuseTntChance) return net.minecraft.world.InteractionResult.PASS;
+
+ net.minecraft.world.entity.item.ItemEntity tntItem = new net.minecraft.world.entity.item.ItemEntity(serverWorld, getX(), getY(), getZ(),
+ new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.TNT));
+ tntItem.setPickUpDelay(10);
+
+ inHand.hurtAndBreak(1, player, hand.asEquipmentSlot());
+ serverWorld.addFreshEntity(tntItem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CUSTOM);
+
+ this.playSound(net.minecraft.sounds.SoundEvents.SHEEP_SHEAR);
+
+ this.kill(serverWorld);
+ return net.minecraft.world.InteractionResult.SUCCESS;
+ }
+
+ return super.interact(player, hand);
+ }
+ // Purpur end - Shears can defuse TNT
}

View File

@@ -0,0 +1,61 @@
--- a/net/minecraft/world/entity/monster/EnderMan.java
+++ b/net/minecraft/world/entity/monster/EnderMan.java
@@ -101,7 +_,7 @@
this.goalSelector.addGoal(11, new EnderMan.EndermanTakeBlockGoal(this));
this.targetSelector.addGoal(1, new EnderMan.EndermanLookForPlayerGoal(this, this::isAngryAt));
this.targetSelector.addGoal(2, new HurtByTargetGoal(this));
- this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Endermite.class, true, false));
+ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Endermite.class, 10, true, false, (entityliving, ignored) -> entityliving.level().purpurConfig.endermanAggroEndermites && entityliving instanceof Endermite endermite && (!entityliving.level().purpurConfig.endermanAggroEndermitesOnlyIfPlayerSpawned || endermite.isPlayerSpawned()))); // Purpur
this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, false));
}
@@ -220,7 +_,7 @@
private boolean isBeingStaredBy(final Player player) {
// Paper start - EndermanAttackPlayerEvent
- final boolean shouldAttack = this.isBeingStaredBy0(player);
+ final boolean shouldAttack = !this.level().purpurConfig.endermanDisableStareAggro && this.isBeingStaredBy0(player); // Purpur - Config to ignore Dragon Head wearers and stare aggro
final com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
event.setCancelled(!shouldAttack);
return event.callEvent();
@@ -373,6 +_,7 @@
public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) {
if (this.isInvulnerableTo(level, source)) {
return false;
+ } else if (org.purpurmc.purpur.PurpurConfig.endermanShortHeight && damageSource.is(net.minecraft.world.damagesource.DamageTypes.IN_WALL)) { return false; // Purpur - no suffocation damage if short height - Short enderman height
} else {
AbstractThrownPotion thrownPotion = source.getDirectEntity() instanceof AbstractThrownPotion potion ? potion : null;
if (!source.is(DamageTypeTags.IS_PROJECTILE) && thrownPotion == null) { // Paper - EndermanEscapeEvent - diff on change - below logic relies on this path covering non-projectile damage.
@@ -387,6 +_,7 @@
} else {
boolean hurtWithCleanWater = thrownPotion != null && this.hurtWithCleanWater(level, source, thrownPotion, damage);
+ if (!flag && level.purpurConfig.endermanIgnoreProjectiles) return super.hurtServer(level, damageSource, amount); // Purpur - Config to disable Enderman teleport on projectile hit
if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - EndermanEscapeEvent
for (int i = 0; i < 64; i++) {
if (this.teleport()) {
@@ -430,7 +_,7 @@
@Override
public boolean requiresCustomPersistence() {
- return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
+ return super.requiresCustomPersistence() || (!this.level().purpurConfig.endermanDespawnEvenWithBlock && this.getCarriedBlock() != null); // Purpur - Add config for allowing Endermen to despawn even while holding a block
}
private static class EndermanFreezeWhenLookedAt extends Goal {
@@ -473,6 +_,7 @@
@Override
public boolean canUse() {
+ if (!enderman.level().purpurConfig.endermanAllowGriefing) return false; // Purpur - Add enderman and creeper griefing controls
return this.enderman.getCarriedBlock() != null
&& getServerLevel(this.enderman).getGameRules().get(GameRules.MOB_GRIEFING)
&& this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0;
@@ -616,6 +_,7 @@
@Override
public boolean canUse() {
+ if (!enderman.level().purpurConfig.endermanAllowGriefing) return false; // Purpur - Add enderman and creeper griefing controls
return this.enderman.getCarriedBlock() == null
&& getServerLevel(this.enderman).getGameRules().get(GameRules.MOB_GRIEFING)
&& this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0;

View File

@@ -0,0 +1,41 @@
--- a/net/minecraft/world/entity/monster/Endermite.java
+++ b/net/minecraft/world/entity/monster/Endermite.java
@@ -30,12 +_,23 @@
private static final int MAX_LIFE = 2400;
private static final int DEFAULT_LIFE = 0;
public int life = 0;
+ private boolean isPlayerSpawned; // Purpur - Add back player spawned endermite API
public Endermite(final EntityType<? extends Endermite> type, final Level level) {
super(type, level);
this.xpReward = 3;
}
+ // Purpur start - Add back player spawned endermite API
+ public boolean isPlayerSpawned() {
+ return this.isPlayerSpawned;
+ }
+
+ public void setPlayerSpawned(boolean playerSpawned) {
+ this.isPlayerSpawned = playerSpawned;
+ }
+ // Purpur end - Add back player spawned endermite API
+
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new FloatGoal(this));
@@ -81,12 +_,14 @@
protected void readAdditionalSaveData(final ValueInput input) {
super.readAdditionalSaveData(input);
this.life = input.getIntOr("Lifetime", 0);
+ this.isPlayerSpawned = input.getBooleanOr("PlayerSpawned", false); // Purpur - Add back player spawned endermite API
}
@Override
protected void addAdditionalSaveData(final ValueOutput output) {
super.addAdditionalSaveData(output);
output.putInt("Lifetime", this.life);
+ output.putBoolean("PlayerSpawned", this.isPlayerSpawned); // Purpur - Add back player spawned endermite API
}
@Override

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/Guardian.java
+++ b/net/minecraft/world/entity/monster/Guardian.java
@@ -308,6 +_,11 @@
final BlockPos pos,
final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
return (random.nextInt(20) == 0 || !level.canSeeSkyFromBelowWater(pos))
&& level.getDifficulty() != Difficulty.PEACEFUL
&& (EntitySpawnReason.isSpawner(spawnReason) || level.getFluidState(pos).is(FluidTags.WATER))

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/MagmaCube.java
+++ b/net/minecraft/world/entity/monster/MagmaCube.java
@@ -31,6 +_,11 @@
public static boolean checkMagmaCubeSpawnRules(
final EntityType<MagmaCube> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (net.minecraft.world.entity.monster.Monster.canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
return level.getDifficulty() != Difficulty.PEACEFUL;
}

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/monster/Shulker.java
+++ b/net/minecraft/world/entity/monster/Shulker.java
@@ -81,7 +_,7 @@
Vec3i forwardNormal = Direction.SOUTH.getUnitVec3i();
return new Vector3f(forwardNormal.getX(), forwardNormal.getY(), forwardNormal.getZ());
});
- public static final float MAX_SCALE = 3.0F;
+ private static final float MAX_SCALE = 3.0F;
private float currentPeekAmountO;
private float currentPeekAmount;
private @Nullable BlockPos clientOldAttachPosition;

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/Slime.java
+++ b/net/minecraft/world/entity/monster/Slime.java
@@ -299,6 +_,11 @@
public static boolean checkSlimeSpawnRules(
final EntityType<Slime> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (net.minecraft.world.entity.monster.Monster.canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
if (level.getDifficulty() != Difficulty.PEACEFUL) {
if (EntitySpawnReason.isSpawner(spawnReason)) {
return checkMobSpawnRules(type, level, spawnReason, pos, random);

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
@@ -173,6 +_,11 @@
public static boolean checkHoglinSpawnRules(
final EntityType<Hoglin> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (net.minecraft.world.entity.monster.Monster.canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
return !level.getBlockState(pos.below()).is(Blocks.NETHER_WART_BLOCK);
}

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
@@ -181,6 +_,11 @@
public static boolean checkPiglinSpawnRules(
final EntityType<Piglin> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
return !level.getBlockState(pos.below()).is(Blocks.NETHER_WART_BLOCK);
}

View File

@@ -0,0 +1,67 @@
--- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java
+++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java
@@ -130,4 +_,64 @@
SoundEvent getStepSound() {
return SoundEvents.SKELETON_STEP;
}
+
+ // Purpur start - Skeletons eat wither roses
+ private int witherRosesFed = 0;
+
+ @Override
+ public net.minecraft.world.InteractionResult mobInteract(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) {
+ net.minecraft.world.item.ItemStack stack = player.getItemInHand(hand);
+
+ if (level().purpurConfig.skeletonFeedWitherRoses > 0 && this.getType() != EntityType.WITHER_SKELETON && stack.getItem() == net.minecraft.world.level.block.Blocks.WITHER_ROSE.asItem()) {
+ return this.feedWitherRose(player, stack);
+ }
+
+ return super.mobInteract(player, hand);
+ }
+
+ private net.minecraft.world.InteractionResult feedWitherRose(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack) {
+ if (++witherRosesFed < level().purpurConfig.skeletonFeedWitherRoses) {
+ if (!player.getAbilities().instabuild) {
+ stack.shrink(1);
+ }
+ return net.minecraft.world.InteractionResult.CONSUME;
+ }
+
+ WitherSkeleton skeleton = EntityType.WITHER_SKELETON.create(level(), net.minecraft.world.entity.EntitySpawnReason.CONVERSION);
+ if (skeleton == null) {
+ return net.minecraft.world.InteractionResult.PASS;
+ }
+
+ skeleton.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ skeleton.setHealth(this.getHealth());
+ skeleton.setAggressive(this.isAggressive());
+ skeleton.copyPosition(this);
+ skeleton.setYBodyRot(this.yBodyRot);
+ skeleton.setYHeadRot(this.getYHeadRot());
+ skeleton.yRotO = this.yRotO;
+ skeleton.xRotO = this.xRotO;
+
+ if (this.hasCustomName()) {
+ skeleton.setCustomName(this.getCustomName());
+ }
+
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, skeleton, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return net.minecraft.world.InteractionResult.PASS;
+ }
+
+ this.level().addFreshEntity(skeleton);
+ this.remove(RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ if (!player.getAbilities().instabuild) {
+ stack.shrink(1);
+ }
+
+ for (int i = 0; i < 15; ++i) {
+ ((net.minecraft.server.level.ServerLevel) level()).sendParticlesSource(((net.minecraft.server.level.ServerLevel) level()).players(), null, net.minecraft.core.particles.ParticleTypes.HAPPY_VILLAGER,
+ false, true,
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 2), getZ() + random.nextFloat(), 1,
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0);
+ }
+ return net.minecraft.world.InteractionResult.SUCCESS;
+ }
+ // Purpur end - Skeletons eat wither roses
}

View File

@@ -0,0 +1,21 @@
--- a/net/minecraft/world/entity/monster/warden/WardenAi.java
+++ b/net/minecraft/world/entity/monster/warden/WardenAi.java
@@ -139,15 +_,16 @@
return ActivityData.create(
Activity.FIGHT,
10,
- ImmutableList.of(
+ ImmutableList.copyOf(java.util.stream.Stream.<BehaviorControl<? super Warden>>of( // Purpur - configurable warden sonic boom
DIG_COOLDOWN_SETTER,
StopAttackingIfTargetInvalid.<Warden>create(
(level, target) -> !body.getAngerLevel().isAngry() || !body.canTargetEntity(target), WardenAi::onTargetInvalid, false
),
SetEntityLookTarget.create(entity -> isTarget(body, entity), (float)body.getAttributeValue(Attributes.FOLLOW_RANGE)),
SetWalkTargetFromAttackTargetIfTargetOutOfReach.create(1.2F),
- new SonicBoom(),
+ warden.level().purpurConfig.wardenCanUseSonicBoom ? new SonicBoom() : null, // Purpur - configurable warden sonic boom
MeleeAttack.create(18)
+ ).filter(java.util.Objects::nonNull).toList() // Purpur - configurable warden sonic boom
),
MemoryModuleType.ATTACK_TARGET
);

View File

@@ -0,0 +1,32 @@
--- a/net/minecraft/world/entity/monster/zombie/Zombie.java
+++ b/net/minecraft/world/entity/monster/zombie/Zombie.java
@@ -127,7 +_,19 @@
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
- if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Spigot
+ // Purpur start - Add option to disable zombie aggressiveness towards villagers
+ if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false) { // Spigot
+ @Override
+ public boolean canUse() {
+ return (level().purpurConfig.zombieAggressiveTowardsVillagerWhenLagging || !level().getServer().server.isLagging()) && super.canUse();
+ }
+
+ @Override
+ public boolean canContinueToUse() {
+ return (level().purpurConfig.zombieAggressiveTowardsVillagerWhenLagging || !level().getServer().server.isLagging()) && super.canContinueToUse();
+ }
+ });
+ // Purpur end - Add option to disable zombie aggressiveness towards villagers
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
}
@@ -542,7 +_,7 @@
}
}
- if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && SpecialDates.isHalloween() && random.nextFloat() < 0.25F) {
+ if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty() && (level.getLevel().purpurConfig.forceHalloweenSeason || SpecialDates.isHalloween()) && random.nextFloat() < level.getLevel().purpurConfig.chanceHeadHalloweenOnEntity) { // Purpur - Halloween options and optimizations
this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
this.setDropChance(EquipmentSlot.HEAD, 0.0F);
}

View File

@@ -0,0 +1,40 @@
--- a/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java
+++ b/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java
@@ -113,6 +_,12 @@
this.maybeAlertOthers();
}
+ // Purpur start - Toggle for Zombified Piglin death always counting as player kill when angry
+ if (this.isAngry() && this.level().purpurConfig.zombifiedPiglinCountAsPlayerKillWhenAngry) {
+ this.lastHurtByPlayerMemoryTime = this.tickCount;
+ }
+ // Purpur end - Toggle for Zombified Piglin death always counting as player kill when angry
+
super.customServerAiStep(level);
}
@@ -160,6 +_,12 @@
this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random);
}
+ // Purpur start - Toggle for Zombified Piglin death always counting as player kill when angry
+ if (target instanceof Player player && this.level().purpurConfig.zombifiedPiglinCountAsPlayerKillWhenAngry) {
+ this.setLastHurtByPlayer(player, this.tickCount);
+ }
+ // Purpur end - Toggle for Zombified Piglin death always counting as player kill when angry
+
return super.setTarget(target, reason); // CraftBukkit
}
@@ -180,6 +_,11 @@
public static boolean checkZombifiedPiglinSpawnRules(
final EntityType<ZombifiedPiglin> type, final LevelAccessor level, final EntitySpawnReason spawnReason, final BlockPos pos, final RandomSource random
) {
+ // Purpur start - Config to disable hostile mob spawn on ice
+ if (canSpawnInBlueAndPackedIce(level, pos)) {
+ return false;
+ }
+ // Purpur end - Config to disable hostile mob spawn on ice
return level.getDifficulty() != Difficulty.PEACEFUL && !level.getBlockState(pos.below()).is(Blocks.NETHER_WART_BLOCK);
}

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -1519,7 +_,7 @@
}
@Override
- public boolean canGlide() {
+ protected boolean canGlide() {
return !this.abilities.flying && super.canGlide();
}

View File

@@ -0,0 +1,23 @@
--- a/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java
+++ b/net/minecraft/world/entity/projectile/arrow/AbstractArrow.java
@@ -78,6 +_,7 @@
private @Nullable List<Entity> piercedAndKilledEntities;
public ItemStack pickupItemStack = this.getDefaultPickupItem();
public @Nullable ItemStack firedFromWeapon = null;
+ public net.minecraft.world.item.enchantment.ItemEnchantments actualEnchantments = net.minecraft.world.item.enchantment.ItemEnchantments.EMPTY; // Purpur - Add an option to fix MC-3304 projectile looting
protected AbstractArrow(final EntityType<? extends AbstractArrow> type, final Level level) {
super(type, level);
@@ -605,6 +_,12 @@
public @Nullable ItemStack getWeaponItem() {
return this.firedFromWeapon;
}
+
+ // Purpur start - Add an option to fix MC-3304 projectile looting
+ public void setActualEnchantments(net.minecraft.world.item.enchantment.ItemEnchantments actualEnchantments) {
+ this.actualEnchantments = actualEnchantments;
+ }
+ // Purpur end - Add an option to fix MC-3304 projectile looting
protected SoundEvent getDefaultHitGroundSoundEvent() {
return SoundEvents.ARROW_HIT;

View File

@@ -0,0 +1,25 @@
--- a/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java
+++ b/net/minecraft/world/entity/projectile/hurtingprojectile/WitherSkull.java
@@ -94,7 +_,7 @@
super.onHit(hitResult);
if (!this.level().isClientSide()) {
// CraftBukkit start
- org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false);
+ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), this.level().purpurConfig.witherExplosionRadius, false); // Purpur - Config for wither explosion radius
if (event.callEvent()) {
this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB);
}
@@ -102,6 +_,13 @@
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
+
+ // Purpur start - Add canSaveToDisk to Entity
+ @Override
+ public boolean canSaveToDisk() {
+ return false;
+ }
+ // Purpur end - Add canSaveToDisk to Entity
@Override
protected void defineSynchedData(final SynchedEntityData.Builder entityData) {