mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 10:57:43 +01:00
apply and rebuild already applied source patches
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 8dff36deb47de619f6958cead3c648c832ecc171..f532809a855562b43545e45957bd28c207bd4547 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -148,6 +148,7 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
|
||||
+ public static javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino"); // Purpur - Configurable entity base attributes
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first snapTo
|
||||
@@ -280,8 +281,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public double xOld;
|
||||
public double yOld;
|
||||
public double zOld;
|
||||
+ public float maxUpStep; // Purpur - Add option to set armorstand step height
|
||||
public boolean noPhysics;
|
||||
- public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random
|
||||
+ public final RandomSource random; // Paper - Share random for entities to make them more random // Add toggle for RNG manipulation
|
||||
public int tickCount;
|
||||
private int remainingFireTicks;
|
||||
public boolean wasTouchingWater;
|
||||
@@ -315,8 +317,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public PortalProcessor portalProcess;
|
||||
public int portalCooldown;
|
||||
private boolean invulnerable;
|
||||
- protected UUID uuid = Mth.createInsecureUUID(this.random);
|
||||
- protected String stringUUID = this.uuid.toString();
|
||||
+ protected UUID uuid; // Purpur - Add toggle for RNG manipulation
|
||||
+ protected String stringUUID; // Purpur - Add toggle for RNG manipulation
|
||||
private boolean hasGlowingTag;
|
||||
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};
|
||||
@@ -371,6 +373,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean isTemporarilyActive;
|
||||
public long activatedImmunityTick = Integer.MIN_VALUE;
|
||||
+ public @Nullable Boolean immuneToFire = null; // Purpur - Fire immune API
|
||||
|
||||
public void inactiveTick() {
|
||||
}
|
||||
@@ -533,10 +536,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
// Paper end - optimise entity tracker
|
||||
|
||||
+ // Purpur start - Add canSaveToDisk to Entity
|
||||
+ public boolean canSaveToDisk() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Purpur end - Add canSaveToDisk to Entity
|
||||
+
|
||||
public Entity(EntityType<?> entityType, Level level) {
|
||||
this.type = entityType;
|
||||
this.level = level;
|
||||
this.dimensions = entityType.getDimensions();
|
||||
+ // Purpur start - Add toggle for RNG manipulation
|
||||
+ this.random = level == null || level.purpurConfig.entitySharedRandom ? SHARED_RANDOM : RandomSource.create();
|
||||
+ this.uuid = Mth.createInsecureUUID(this.random);
|
||||
+ this.stringUUID = this.uuid.toString();
|
||||
+ // Purpur end - Add toggle for RNG manipulation
|
||||
this.position = Vec3.ZERO;
|
||||
this.blockPosition = BlockPos.ZERO;
|
||||
this.chunkPosition = ChunkPos.ZERO;
|
||||
@@ -911,6 +925,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
&& this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> this.getY() >= v)
|
||||
&& (!(this instanceof Player player) || !player.getAbilities().invulnerable))) {
|
||||
// Paper end - Configurable nether ceiling damage
|
||||
+ if (this.level.purpurConfig.teleportOnNetherCeilingDamage && this.level.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER && this instanceof ServerPlayer player) player.teleport(org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.level.getSharedSpawnPos(), this.level)); else // Purpur - Add option to teleport to spawn on nether ceiling damage
|
||||
this.onBelowWorld();
|
||||
}
|
||||
}
|
||||
@@ -1889,7 +1904,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public boolean fireImmune() {
|
||||
- return this.getType().fireImmune();
|
||||
+ return this.immuneToFire != null ? immuneToFire : this.getType().fireImmune(); // Purpur - add fire immune API
|
||||
}
|
||||
|
||||
public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) {
|
||||
@@ -2585,6 +2600,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
output.putBoolean("Paper.FreezeLock", true);
|
||||
}
|
||||
// Paper end
|
||||
+ // Purpur start - Fire immune API
|
||||
+ if (immuneToFire != null) {
|
||||
+ output.putBoolean("Purpur.FireImmune", immuneToFire);
|
||||
+ }
|
||||
+ // Purpur end - Fire immune API
|
||||
} catch (Throwable var7) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved");
|
||||
@@ -2705,6 +2725,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
freezeLocked = input.getBooleanOr("Paper.FreezeLock", false);
|
||||
// Paper end
|
||||
+
|
||||
+ immuneToFire = input.read("Purpur.FireImmune", com.mojang.serialization.Codec.BOOL).orElse(null); // Purpur - Fire immune API
|
||||
+
|
||||
} catch (Throwable var7) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded");
|
||||
@@ -2983,6 +3006,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (this.isAlive() && this instanceof Leashable leashable2) {
|
||||
if (leashable2.getLeashHolder() == player) {
|
||||
if (!this.level().isClientSide()) {
|
||||
+ if (hand == InteractionHand.OFF_HAND && (level().purpurConfig.villagerCanBeLeashed || level().purpurConfig.wanderingTraderCanBeLeashed) && this instanceof net.minecraft.world.entity.npc.AbstractVillager) return InteractionResult.CONSUME; // Purpur - Allow leashing villagers
|
||||
// Paper start - EntityUnleashEvent
|
||||
if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerUnleashEntityEvent(
|
||||
leashable2, player, hand, !player.hasInfiniteMaterials(), true
|
||||
@@ -3388,15 +3412,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return Vec3.directionFromRotation(this.getRotationVector());
|
||||
}
|
||||
|
||||
+ public BlockPos portalPos = BlockPos.ZERO; // Purpur - Fix stuck in portals
|
||||
public void setAsInsidePortal(Portal portal, BlockPos pos) {
|
||||
if (this.isOnPortalCooldown()) {
|
||||
+ if (!(level().purpurConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(this.portalPos))) // Purpur - Fix stuck in portals
|
||||
this.setPortalCooldown();
|
||||
- } else {
|
||||
+ } else if (this.level.purpurConfig.entitiesCanUsePortals || this instanceof ServerPlayer) { // Purpur - Entities can use portals
|
||||
if (this.portalProcess == null || !this.portalProcess.isSamePortal(portal)) {
|
||||
this.portalProcess = new PortalProcessor(portal, pos.immutable());
|
||||
} else if (!this.portalProcess.isInsidePortalThisTick()) {
|
||||
this.portalProcess.updateEntryPosition(pos.immutable());
|
||||
this.portalProcess.setAsInsidePortalThisTick(true);
|
||||
+ this.portalPos = BlockPos.ZERO; // Purpur - Fix stuck in portals
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3601,7 +3628,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public int getMaxAirSupply() {
|
||||
- return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ return this.level == null? this.maxAirTicks : this.level().purpurConfig.drowningAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() // Purpur - Drowning Settings
|
||||
}
|
||||
|
||||
public int getAirSupply() {
|
||||
@@ -4155,7 +4182,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// CraftBukkit end
|
||||
|
||||
public boolean canUsePortal(boolean allowPassengers) {
|
||||
- return (allowPassengers || !this.isPassenger()) && this.isAlive();
|
||||
+ return (allowPassengers || !this.isPassenger()) && this.isAlive() && (this.level.purpurConfig.entitiesCanUsePortals || this instanceof ServerPlayer); // Purpur - Entities can use portals
|
||||
}
|
||||
|
||||
public boolean canTeleport(Level fromLevel, Level toLevel) {
|
||||
@@ -4680,6 +4707,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return Mth.lerp(partialTick, this.yRotO, this.yRot);
|
||||
}
|
||||
|
||||
+ // Purpur start - Stop squids floating on top of water
|
||||
+ public AABB getAxisForFluidCheck() {
|
||||
+ return this.getBoundingBox().deflate(0.001D);
|
||||
+ }
|
||||
+ // Purpur end - Stop squids floating on top of water
|
||||
+
|
||||
// Paper start - optimise collisions
|
||||
public boolean updateFluidHeightAndDoFluidPushing(final TagKey<Fluid> fluid, final double flowScale) {
|
||||
if (this.touchingUnloadedChunk()) {
|
||||
@@ -5106,7 +5139,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public float maxUpStep() {
|
||||
- return 0.0F;
|
||||
+ return maxUpStep; // Purpur - Add option to set armorstand step height
|
||||
}
|
||||
|
||||
public void onExplosionHit(@Nullable Entity entity) {
|
||||
@@ -0,0 +1,178 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index c3c3b7dfb01317c902687b7de192f8a5a910a565..92ef84721a75b85331b936a808c3beb3585aefab 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -444,6 +444,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
if (d < 0.0) {
|
||||
double damagePerBlock = serverLevel1.getWorldBorder().getDamagePerBlock();
|
||||
if (damagePerBlock > 0.0) {
|
||||
+ // Purpur start - Add option to teleport to spawn if outside world border
|
||||
+ if (this.level().purpurConfig.teleportIfOutsideBorder && this instanceof ServerPlayer serverPlayer) {
|
||||
+ serverPlayer.teleport(org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.level().getSharedSpawnPos(), this.level()));
|
||||
+ return;
|
||||
+ }
|
||||
+ // Purpur end - Add option to teleport to spawn if outside world border
|
||||
this.hurtServer(serverLevel1, this.damageSources().outOfBorder(), Math.max(1, Mth.floor(-d * damagePerBlock)));
|
||||
}
|
||||
}
|
||||
@@ -456,10 +462,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
&& (!flag || !((Player)this).getAbilities().invulnerable);
|
||||
if (flag1) {
|
||||
this.setAirSupply(this.decreaseAirSupply(this.getAirSupply()));
|
||||
- if (this.getAirSupply() == -20) {
|
||||
+ if (this.getAirSupply() == -this.level().purpurConfig.drowningDamageInterval) { // Purpur - Drowning Settings
|
||||
this.setAirSupply(0);
|
||||
serverLevel1.broadcastEntityEvent(this, (byte)67);
|
||||
- this.hurtServer(serverLevel1, this.damageSources().drown(), 2.0F);
|
||||
+ this.hurtServer(serverLevel1, this.damageSources().drown(), (float) this.level().purpurConfig.damageFromDrowning); // Purpur - Drowning Settings
|
||||
}
|
||||
} else if (this.getAirSupply() < this.getMaxAirSupply()) {
|
||||
this.setAirSupply(this.increaseAirSupply(this.getAirSupply()));
|
||||
@@ -1039,15 +1045,33 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
if (lookingEntity != null) {
|
||||
ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
EntityType<?> type = lookingEntity.getType();
|
||||
- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)
|
||||
- || type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)
|
||||
- || type == EntityType.PIGLIN && itemBySlot.is(Items.PIGLIN_HEAD)
|
||||
- || type == EntityType.PIGLIN_BRUTE && itemBySlot.is(Items.PIGLIN_HEAD)
|
||||
- || type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
|
||||
- d *= 0.5;
|
||||
+ // Purpur start - Mob head visibility percent
|
||||
+ if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)) {
|
||||
+ d *= lookingEntity.level().purpurConfig.skeletonHeadVisibilityPercent;
|
||||
+ }
|
||||
+ else if (type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)) {
|
||||
+ d *= lookingEntity.level().purpurConfig.zombieHeadVisibilityPercent;
|
||||
}
|
||||
+ else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && itemBySlot.is(Items.PIGLIN_HEAD)) {
|
||||
+ d *= lookingEntity.level().purpurConfig.piglinHeadVisibilityPercent;
|
||||
+ }
|
||||
+ else if (type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
|
||||
+ d *= lookingEntity.level().purpurConfig.creeperHeadVisibilityPercent;
|
||||
+ }
|
||||
+ // Purpur end - Mob head visibility percent
|
||||
}
|
||||
|
||||
+ // Purpur start - Configurable mob blindness
|
||||
+ if (lookingEntity instanceof LivingEntity entityliving) {
|
||||
+ if (entityliving.hasEffect(MobEffects.BLINDNESS)) {
|
||||
+ int amplifier = entityliving.getEffect(MobEffects.BLINDNESS).getAmplifier();
|
||||
+ for (int i = 0; i < amplifier; i++) {
|
||||
+ d *= this.level().purpurConfig.mobsBlindnessMultiplier;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Configurable mob blindness
|
||||
+
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -1093,6 +1117,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
Iterator<MobEffectInstance> iterator = this.activeEffects.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance effect = iterator.next();
|
||||
+ if (cause == EntityPotionEffectEvent.Cause.MILK && !this.level().purpurConfig.milkClearsBeneficialEffects && effect.getEffect().value().isBeneficial()) continue; // Purpur - Milk Keeps Beneficial Effects
|
||||
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
|
||||
if (event.isCancelled()) {
|
||||
continue;
|
||||
@@ -1417,6 +1442,24 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
this.stopSleeping();
|
||||
}
|
||||
|
||||
+ // Purpur start - One Punch Man!
|
||||
+ if (damageSource.getEntity() instanceof net.minecraft.world.entity.player.Player player && damageSource.getEntity().level().purpurConfig.creativeOnePunch && !damageSource.is(DamageTypeTags.IS_PROJECTILE)) {
|
||||
+ if (player.isCreative()) {
|
||||
+ org.apache.commons.lang3.mutable.MutableDouble attackDamage = new org.apache.commons.lang3.mutable.MutableDouble();
|
||||
+ player.getMainHandItem().forEachModifier(EquipmentSlot.MAINHAND, (attributeHolder, attributeModifier) -> {
|
||||
+ if (attributeModifier.operation() == AttributeModifier.Operation.ADD_VALUE) {
|
||||
+ attackDamage.addAndGet(attributeModifier.amount());
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ if (attackDamage.doubleValue() == 0.0D) {
|
||||
+ // One punch!
|
||||
+ amount = 9999F;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - One Punch Man!
|
||||
+
|
||||
this.noActionTime = 0;
|
||||
if (amount < 0.0F) {
|
||||
amount = 0.0F;
|
||||
@@ -1678,10 +1721,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
protected Player resolvePlayerResponsibleForDamage(DamageSource damageSource) {
|
||||
Entity entity = damageSource.getEntity();
|
||||
if (entity instanceof Player player) {
|
||||
- this.setLastHurtByPlayer(player, 100);
|
||||
+ this.setLastHurtByPlayer(player, this.level().purpurConfig.mobLastHurtByPlayerTime); // Purpur - Config for mob last hurt by player time
|
||||
} else if (entity instanceof Wolf wolf && wolf.isTame()) {
|
||||
if (wolf.getOwnerReference() != null) {
|
||||
- this.setLastHurtByPlayer(wolf.getOwnerReference().getUUID(), 100);
|
||||
+ this.setLastHurtByPlayer(wolf.getOwnerReference().getUUID(), this.level().purpurConfig.mobLastHurtByPlayerTime); // Purpur - Config for mob last hurt by player time
|
||||
} else {
|
||||
this.lastHurtByPlayer = null;
|
||||
this.lastHurtByPlayerMemoryTime = 0;
|
||||
@@ -1732,6 +1775,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - Totems work in inventory
|
||||
+ if (level().purpurConfig.totemOfUndyingWorksInInventory && this instanceof ServerPlayer player && (itemStack == null || itemStack.getItem() != Items.TOTEM_OF_UNDYING) && player.getBukkitEntity().hasPermission("purpur.inventory_totem")) {
|
||||
+ for (ItemStack item : player.getInventory().getNonEquipmentItems()) {
|
||||
+ if (item.getItem() == Items.TOTEM_OF_UNDYING) {
|
||||
+ itemInHand = item;
|
||||
+ itemStack = item.copy();
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Totems work in inventory
|
||||
+
|
||||
final org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null;
|
||||
final EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot);
|
||||
event.setCancelled(itemStack == null);
|
||||
@@ -1907,6 +1962,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
boolean flag = this.lastHurtByPlayerMemoryTime > 0;
|
||||
this.dropEquipment(level); // CraftBukkit - from below
|
||||
if (this.shouldDropLoot() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ if (!(damageSource.is(net.minecraft.world.damagesource.DamageTypes.CRAMMING) && level().purpurConfig.disableDropsOnCrammingDeath)) { // Purpur - Disable loot drops on death by cramming
|
||||
this.dropFromLootTable(level, damageSource, flag);
|
||||
// Paper start
|
||||
final boolean prev = this.clearEquipmentSlots;
|
||||
@@ -1915,6 +1971,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
// Paper end
|
||||
this.dropCustomDeathLoot(level, damageSource, flag);
|
||||
this.clearEquipmentSlots = prev; // Paper
|
||||
+ } // Purpur - Disable loot drops on death by cramming
|
||||
}
|
||||
|
||||
// CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment
|
||||
@@ -3109,6 +3166,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
float f = (float)(d * 10.0 - 3.0);
|
||||
if (f > 0.0F) {
|
||||
this.playSound(this.getFallDamageSound((int)f), 1.0F, 1.0F);
|
||||
+ if (level().purpurConfig.elytraKineticDamage) // Purpur - Toggle for kinetic damage
|
||||
this.hurt(this.damageSources().flyIntoWall(), f);
|
||||
}
|
||||
}
|
||||
@@ -4518,6 +4576,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
: slot == equippable.slot() && this.canUseSlot(equippable.slot()) && equippable.canBeEquippedBy(this.getType());
|
||||
}
|
||||
|
||||
+ // Purpur start - Dispenser curse of binding protection
|
||||
+ public @Nullable EquipmentSlot getEquipmentSlotForDispenserItem(ItemStack itemstack) {
|
||||
+ return EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BINDING_CURSE, itemstack) > 0 ? null : this.getEquipmentSlotForItem(itemstack);
|
||||
+ }
|
||||
+ // Purpur end - Dispenser curse of binding protection
|
||||
+
|
||||
private static SlotAccess createEquipmentSlotAccess(LivingEntity entity, EquipmentSlot slot) {
|
||||
return slot != EquipmentSlot.HEAD && slot != EquipmentSlot.MAINHAND && slot != EquipmentSlot.OFFHAND
|
||||
? SlotAccess.forEquipmentSlot(entity, slot, itemStack -> itemStack.isEmpty() || entity.getEquipmentSlotForItem(itemStack) == slot)
|
||||
@@ -0,0 +1,88 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index e0b3cb2b2694768803ed347a1026b881fd624951..150d12e27c2de0740af5c554286358f81e290fae 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -140,6 +140,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
private int homeRadius = -1;
|
||||
public boolean aware = true; // CraftBukkit
|
||||
public net.kyori.adventure.util.TriState despawnInPeacefulOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - allow changing despawnInPeaceful
|
||||
+ public int ticksSinceLastInteraction; // Purpur - Entity lifespan
|
||||
|
||||
protected Mob(EntityType<? extends Mob> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -285,6 +286,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
target = null;
|
||||
}
|
||||
}
|
||||
+ if (target instanceof net.minecraft.server.level.ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur - Entity lifespan
|
||||
this.target = target;
|
||||
return true;
|
||||
// CraftBukkit end
|
||||
@@ -328,8 +330,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
}
|
||||
|
||||
profilerFiller.pop();
|
||||
+ incrementTicksSinceLastInteraction(); // Purpur - Entity lifespan
|
||||
}
|
||||
|
||||
+ // Purpur start - Entity lifespan
|
||||
+ private void incrementTicksSinceLastInteraction() {
|
||||
+ ++this.ticksSinceLastInteraction;
|
||||
+ if (getRider() != null) {
|
||||
+ this.ticksSinceLastInteraction = 0;
|
||||
+ return;
|
||||
+ }
|
||||
+ if (this.level().purpurConfig.entityLifeSpan <= 0) {
|
||||
+ return; // feature disabled
|
||||
+ }
|
||||
+ if (!this.removeWhenFarAway(0) || isPersistenceRequired() || requiresCustomPersistence() || hasCustomName()) {
|
||||
+ return; // mob persistent
|
||||
+ }
|
||||
+ if (this.ticksSinceLastInteraction > this.level().purpurConfig.entityLifeSpan) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Entity lifespan
|
||||
+
|
||||
@Override
|
||||
protected void playHurtSound(DamageSource source) {
|
||||
this.resetAmbientSoundTime();
|
||||
@@ -433,6 +455,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
output.putString("Paper.DespawnInPeacefulOverride", this.despawnInPeacefulOverride.name());
|
||||
}
|
||||
// Paper end - allow changing despawnInPeaceful
|
||||
+ output.putInt("Purpur.ticksSinceLastInteraction", this.ticksSinceLastInteraction); // Purpur - Entity lifespan
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -461,6 +484,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
this.setNoAi(input.getBooleanOr("NoAI", false));
|
||||
this.aware = input.getBooleanOr("Bukkit.Aware", true); // CraftBukkit
|
||||
this.despawnInPeacefulOverride = input.read("Paper.DespawnInPeacefulOverride", io.papermc.paper.util.PaperCodecs.TRI_STATE_CODEC).orElse(net.kyori.adventure.util.TriState.NOT_SET); // Paper - allow changing despawnInPeaceful
|
||||
+ this.ticksSinceLastInteraction = input.getIntOr("Purpur.ticksSinceLastInteraction", 0); // Purpur- Entity lifespan
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1201,7 +1225,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
);
|
||||
}
|
||||
|
||||
- this.setLeftHanded(random.nextFloat() < 0.05F);
|
||||
+ this.setLeftHanded(random.nextFloat() < level.getLevel().purpurConfig.entityLeftHandedChance); // Purpur - Changeable Mob Left Handed Chance
|
||||
return spawnGroupData;
|
||||
}
|
||||
|
||||
@@ -1538,6 +1562,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
this.playAttackSound();
|
||||
}
|
||||
|
||||
+ if (target instanceof net.minecraft.server.level.ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur - Entity lifespan
|
||||
return flag;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/animal/Bee.java b/net/minecraft/world/entity/animal/Bee.java
|
||||
index 13f24836649790a34b988e2d63accb043e6ff080..a74def8accfbed14257b4090889a6c8d1a3ccd87 100644
|
||||
--- a/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -168,7 +168,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
// Paper end - Fix MC-167279
|
||||
this.lookControl = new Bee.BeeLookControl(this);
|
||||
this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F);
|
||||
- this.setPathfindingMalus(PathType.WATER, -1.0F);
|
||||
+ if (this.level().purpurConfig.beeCanInstantlyStartDrowning) this.setPathfindingMalus(PathType.WATER, -1.0F); // Purpur - bee can instantly start drowning in water option
|
||||
this.setPathfindingMalus(PathType.WATER_BORDER, 16.0F);
|
||||
this.setPathfindingMalus(PathType.COCOA, -1.0F);
|
||||
this.setPathfindingMalus(PathType.FENCE, -1.0F);
|
||||
@@ -366,7 +366,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
}
|
||||
|
||||
public static boolean isNightOrRaining(Level level) {
|
||||
- return level.dimensionType().hasSkyLight() && (level.isDarkOutside() || level.isRaining());
|
||||
+ return level.dimensionType().hasSkyLight() && (level.isDarkOutside() && !level.purpurConfig.beeCanWorkAtNight || level.isRaining() && !level.purpurConfig.beeCanWorkInRain); // Purpur - Bee can work when raining or at night
|
||||
}
|
||||
|
||||
public void setStayOutOfHiveCountdown(int stayOutOfHiveCountdown) {
|
||||
@@ -389,7 +389,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@Override
|
||||
protected void customServerAiStep(ServerLevel level) {
|
||||
boolean hasStung = this.hasStung();
|
||||
- if (this.isInWater()) {
|
||||
+ if (this.level().purpurConfig.beeCanInstantlyStartDrowning && this.isInWater()) { // Purpur - bee can instantly start drowning in water option
|
||||
this.underWaterTicks++;
|
||||
} else {
|
||||
this.underWaterTicks = 0;
|
||||
@@ -399,6 +399,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
this.hurtServer(level, this.damageSources().drown(), 1.0F);
|
||||
}
|
||||
|
||||
+ if (hasStung && !this.level().purpurConfig.beeDiesAfterSting) setHasStung(false); else // Purpur - Stop bees from dying after stinging
|
||||
if (hasStung) {
|
||||
this.timeSinceSting++;
|
||||
if (this.timeSinceSting % 5 == 0 && this.random.nextInt(Mth.clamp(1200 - this.timeSinceSting, 1, 1200)) == 0) {
|
||||
@@ -1133,6 +1134,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
Bee.this.savedFlowerPos = optional.get();
|
||||
Bee.this.navigation
|
||||
.moveTo(Bee.this.savedFlowerPos.getX() + 0.5, Bee.this.savedFlowerPos.getY() + 0.5, Bee.this.savedFlowerPos.getZ() + 0.5, 1.2F);
|
||||
+ new org.purpurmc.purpur.event.entity.BeeFoundFlowerEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level())).callEvent(); // Purpur - Bee API
|
||||
return true;
|
||||
} else {
|
||||
Bee.this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(Bee.this.random, 20, 60);
|
||||
@@ -1179,6 +1181,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
this.pollinating = false;
|
||||
Bee.this.navigation.stop();
|
||||
Bee.this.remainingCooldownBeforeLocatingNewFlower = 200;
|
||||
+ new org.purpurmc.purpur.event.entity.BeeStopPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), Bee.this.savedFlowerPos == null ? null : org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level()), Bee.this.hasNectar()).callEvent(); // Purpur - Bee API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1225,6 +1228,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
this.setWantedPos();
|
||||
}
|
||||
|
||||
+ if (this.successfulPollinatingTicks == 0) new org.purpurmc.purpur.event.entity.BeeStartedPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(Bee.this.savedFlowerPos, Bee.this.level())).callEvent(); // Purpur - Bee API
|
||||
this.successfulPollinatingTicks++;
|
||||
if (Bee.this.random.nextFloat() < 0.05F && this.successfulPollinatingTicks > this.lastSoundPlayedTick + 60) {
|
||||
this.lastSoundPlayedTick = this.successfulPollinatingTicks;
|
||||
@@ -0,0 +1,60 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/animal/Parrot.java b/net/minecraft/world/entity/animal/Parrot.java
|
||||
index 22d1e36dadd6a8cbf615335074426aaab6ea7d01..50d836960e6b2d7dae760ac648b5999d8c58b785 100644
|
||||
--- a/net/minecraft/world/entity/animal/Parrot.java
|
||||
+++ b/net/minecraft/world/entity/animal/Parrot.java
|
||||
@@ -159,6 +159,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(0, new TamableAnimal.TamableAnimalPanicGoal(1.25));
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
+ if (this.level().purpurConfig.parrotBreedable) this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.BreedGoal(this, 1.0D)); // Purpur - Breedable parrots
|
||||
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
|
||||
this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0, 5.0F, 1.0F));
|
||||
@@ -264,7 +265,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
||||
+ if (((this.level().purpurConfig.alwaysTameInCreative && player.hasInfiniteMaterials()) || this.random.nextInt(10) == 0) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit // Purpur - Config to always tame in Creative
|
||||
this.tame(player);
|
||||
this.level().broadcastEntityEvent(this, (byte)7);
|
||||
} else {
|
||||
@@ -272,6 +273,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (this.level().purpurConfig.parrotBreedable) return super.mobInteract(player, hand); // Purpur - Breedable parrots
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (!itemInHand.is(ItemTags.PARROT_POISONOUS_FOOD)) {
|
||||
if (!this.isFlying() && this.isTame() && this.isOwnedBy(player)) {
|
||||
@@ -296,7 +298,7 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean isFood(ItemStack stack) {
|
||||
- return false;
|
||||
+ return this.level().purpurConfig.parrotBreedable && stack.is(ItemTags.PARROT_FOOD); // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
public static boolean checkParrotSpawnRules(
|
||||
@@ -311,13 +313,13 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
|
||||
@Override
|
||||
public boolean canMate(Animal otherAnimal) {
|
||||
- return false;
|
||||
+ return super.canMate(otherAnimal); // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
|
||||
- return null;
|
||||
+ return level.purpurConfig.parrotBreedable ? EntityType.PARROT.create(level, EntitySpawnReason.BREEDING) : null; // Purpur - Breedable parrots
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -0,0 +1,75 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/monster/Skeleton.java b/net/minecraft/world/entity/monster/Skeleton.java
|
||||
index 743bc2986b962d4aaef00d2e457117f375ca65c7..d53364e33bd9e15ad419f306d7cc2e09c9de242c 100644
|
||||
--- a/net/minecraft/world/entity/monster/Skeleton.java
|
||||
+++ b/net/minecraft/world/entity/monster/Skeleton.java
|
||||
@@ -140,4 +140,64 @@ public class Skeleton extends AbstractSkeleton {
|
||||
this.spawnAtLocation(level, Items.SKELETON_SKULL);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // 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) {
|
||||
+ ((ServerLevel) level()).sendParticlesSource(((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
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/monster/ZombieVillager.java b/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
index bc80d5b302f24974ce89db502b41d659457dd98c..75a8f3ecaec5cdfe98aa8363326a8a2047ea75b1 100644
|
||||
--- a/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
+++ b/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
@@ -129,10 +129,10 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
||||
public InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||
ItemStack itemInHand = player.getItemInHand(hand);
|
||||
if (itemInHand.is(Items.GOLDEN_APPLE)) {
|
||||
- if (this.hasEffect(MobEffects.WEAKNESS)) {
|
||||
+ if (this.hasEffect(MobEffects.WEAKNESS) && level().purpurConfig.zombieVillagerCureEnabled) { // Purpur - Add option to disable zombie villagers cure
|
||||
itemInHand.consume(1, player);
|
||||
if (!this.level().isClientSide) {
|
||||
- this.startConverting(player.getUUID(), this.random.nextInt(2401) + 3600);
|
||||
+ this.startConverting(player.getUUID(), this.random.nextInt(level().purpurConfig.zombieVillagerCuringTimeMax - level().purpurConfig.zombieVillagerCuringTimeMin + 1) + level().purpurConfig.zombieVillagerCuringTimeMin); // Purpur - Customizable Zombie Villager curing times
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
@@ -0,0 +1,49 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/CatSpawner.java b/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
index e282b6ab6d0d1c11ee40f5f436bd50fa90ddc88b..d6ae13c19481ce33bfa0b6c9db63283009339d8c 100644
|
||||
--- a/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
@@ -25,7 +25,7 @@ public class CatSpawner implements CustomSpawner {
|
||||
if (spawnFriendlies && level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
||||
this.nextTick--;
|
||||
if (this.nextTick <= 0) {
|
||||
- this.nextTick = 1200;
|
||||
+ this.nextTick = level.purpurConfig.catSpawnDelay; // Purpur - Cat spawning options
|
||||
Player randomPlayer = level.getRandomPlayer();
|
||||
if (randomPlayer != null) {
|
||||
RandomSource randomSource = level.random;
|
||||
@@ -48,9 +48,12 @@ public class CatSpawner implements CustomSpawner {
|
||||
}
|
||||
|
||||
private void spawnInVillage(ServerLevel level, BlockPos pos) {
|
||||
- int i = 48;
|
||||
- if (level.getPoiManager().getCountInRange(holder -> holder.is(PoiTypes.HOME), pos, 48, PoiManager.Occupancy.IS_OCCUPIED) > 4L) {
|
||||
- List<Cat> entitiesOfClass = level.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(48.0, 8.0, 48.0));
|
||||
+ // Purpur start - Cat spawning options
|
||||
+ int range = level.purpurConfig.catSpawnVillageScanRange;
|
||||
+ if (range <= 0) return;
|
||||
+ if (level.getPoiManager().getCountInRange(holder -> holder.is(PoiTypes.HOME), pos, range, PoiManager.Occupancy.IS_OCCUPIED) > 4L) {
|
||||
+ List<Cat> entitiesOfClass = level.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range));
|
||||
+ // Purpur end - Cat spawning options
|
||||
if (entitiesOfClass.size() < 5) {
|
||||
this.spawnCat(pos, level, false);
|
||||
}
|
||||
@@ -58,8 +61,11 @@ public class CatSpawner implements CustomSpawner {
|
||||
}
|
||||
|
||||
private void spawnInHut(ServerLevel level, BlockPos pos) {
|
||||
- int i = 16;
|
||||
- List<Cat> entitiesOfClass = level.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(16.0, 8.0, 16.0));
|
||||
+ // Purpur start - Cat spawning options
|
||||
+ int range = level.purpurConfig.catSpawnSwampHutScanRange;
|
||||
+ if (range <= 0) return;
|
||||
+ List<Cat> entitiesOfClass = level.getEntitiesOfClass(Cat.class, new AABB(pos).inflate(range, 8.0, range));
|
||||
+ // Purpur end - Cat spawning options
|
||||
if (entitiesOfClass.isEmpty()) {
|
||||
this.spawnCat(pos, level, true);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index e5e08dbefead90e9fe2bb05e4f0257f7aa4c0686..fd0322685f17f188d19ccc5fc8d2995bfab17f6e 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -219,11 +219,20 @@ public abstract class Player extends LivingEntity {
|
||||
private int currentImpulseContextResetGraceTime = 0;
|
||||
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
||||
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
||||
+ public int burpDelay = 0; // Purpur - Burp delay
|
||||
+ public boolean canPortalInstant = false; // Purpur - Add portal permission bypass
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
public int oldLevel = -1;
|
||||
|
||||
+ // Purpur start - AFK API
|
||||
+ public abstract void setAfk(boolean afk);
|
||||
+
|
||||
+ public boolean isAfk() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - AFK API
|
||||
@Override
|
||||
public org.bukkit.craftbukkit.entity.CraftHumanEntity getBukkitEntity() {
|
||||
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
|
||||
@@ -287,6 +296,12 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ // Purpur start - Burp delay
|
||||
+ if (this.burpDelay > 0 && --this.burpDelay == 0) {
|
||||
+ this.level().playSound(null, getX(), getY(), getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 1.0F, this.level().random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+ // Purpur end - Burp delay
|
||||
+
|
||||
this.noPhysics = this.isSpectator();
|
||||
if (this.isSpectator() || this.isPassenger()) {
|
||||
this.setOnGround(false);
|
||||
@@ -365,6 +380,17 @@ public abstract class Player extends LivingEntity {
|
||||
this.turtleHelmetTick();
|
||||
}
|
||||
|
||||
+ // Purpur start - Full netherite armor grants fire resistance
|
||||
+ if (this.level().purpurConfig.playerNetheriteFireResistanceDuration > 0 && this.level().getGameTime() % 20 == 0) {
|
||||
+ if (this.getItemBySlot(EquipmentSlot.HEAD).is(Items.NETHERITE_HELMET)
|
||||
+ && this.getItemBySlot(EquipmentSlot.CHEST).is(Items.NETHERITE_CHESTPLATE)
|
||||
+ && this.getItemBySlot(EquipmentSlot.LEGS).is(Items.NETHERITE_LEGGINGS)
|
||||
+ && this.getItemBySlot(EquipmentSlot.FEET).is(Items.NETHERITE_BOOTS)) {
|
||||
+ this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, this.level().purpurConfig.playerNetheriteFireResistanceDuration, this.level().purpurConfig.playerNetheriteFireResistanceAmplifier, this.level().purpurConfig.playerNetheriteFireResistanceAmbient, this.level().purpurConfig.playerNetheriteFireResistanceShowParticles, this.level().purpurConfig.playerNetheriteFireResistanceShowIcon), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.NETHERITE_ARMOR);
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Full netherite armor grants fire resistance
|
||||
+
|
||||
this.cooldowns.tick();
|
||||
this.updatePlayerPose();
|
||||
if (this.currentImpulseContextResetGraceTime > 0) {
|
||||
@@ -630,7 +656,7 @@ public abstract class Player extends LivingEntity {
|
||||
List<Entity> list = Lists.newArrayList();
|
||||
|
||||
for (Entity entity : entities) {
|
||||
- if (entity.getType() == EntityType.EXPERIENCE_ORB) {
|
||||
+ if (entity.getType() == EntityType.EXPERIENCE_ORB && entity.level().purpurConfig.playerExpPickupDelay >= 0) { // Purpur - Configurable player pickup exp delay
|
||||
list.add(entity);
|
||||
} else if (!entity.isRemoved()) {
|
||||
this.touch(entity);
|
||||
@@ -1226,7 +1252,7 @@ public abstract class Player extends LivingEntity {
|
||||
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits
|
||||
if (flag2) {
|
||||
damageSource = damageSource.critical(); // Paper - critical damage API
|
||||
- f *= 1.5F;
|
||||
+ f *= (float) this.level().purpurConfig.playerCriticalDamageMultiplier; // Purpur - Add config change multiplier critical damage value
|
||||
}
|
||||
|
||||
float f2 = f + f1;
|
||||
@@ -1822,7 +1848,23 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
@Override
|
||||
protected int getBaseExperienceReward(ServerLevel level) {
|
||||
- return !level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && !this.isSpectator() ? Math.min(this.experienceLevel * 7, 100) : 0;
|
||||
+ // Purpur start - Add player death exp control options
|
||||
+ if (!level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && !this.isSpectator()) {
|
||||
+ int toDrop;
|
||||
+ try {
|
||||
+ toDrop = Math.round(((Number) scriptEngine.eval("let expLevel = " + experienceLevel + "; " +
|
||||
+ "let expTotal = " + totalExperience + "; " +
|
||||
+ "let exp = " + experienceProgress + "; " +
|
||||
+ level().purpurConfig.playerDeathExpDropEquation)).floatValue());
|
||||
+ } catch (javax.script.ScriptException e) {
|
||||
+ e.printStackTrace();
|
||||
+ toDrop = experienceLevel * 7;
|
||||
+ }
|
||||
+ return Math.min(toDrop, level().purpurConfig.playerDeathExpDropMax);
|
||||
+ } else {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // Purpur end - Add player death exp control options
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1861,6 +1903,13 @@ public abstract class Player extends LivingEntity {
|
||||
return this.inventory.add(stack);
|
||||
}
|
||||
|
||||
+ // Purpur start - Player ridable in water option
|
||||
+ @Override
|
||||
+ public boolean dismountsUnderwater() {
|
||||
+ return !level().purpurConfig.playerRidableInWater;
|
||||
+ }
|
||||
+ // Purpur end - Player ridable in water option
|
||||
+
|
||||
public boolean setEntityOnShoulder(CompoundTag entityCompound) {
|
||||
if (this.isPassenger() || !this.onGround() || this.isInWater() || this.isInPowderSnow) {
|
||||
return false;
|
||||
@@ -0,0 +1,79 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/item/AxeItem.java b/net/minecraft/world/item/AxeItem.java
|
||||
index bd919b9a83f9736f02783b1ba3863fd1b77c7e89..eb8d2d6f9c65185f5fe16a13ab0cdbba78a25a40 100644
|
||||
--- a/net/minecraft/world/item/AxeItem.java
|
||||
+++ b/net/minecraft/world/item/AxeItem.java
|
||||
@@ -62,13 +62,15 @@ public class AxeItem extends Item {
|
||||
if (playerHasBlockingItemUseIntent(context)) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
- Optional<BlockState> optional = this.evaluateNewBlockState(level, clickedPos, player, level.getBlockState(clickedPos));
|
||||
+ Optional<org.purpurmc.purpur.tool.Actionable> optional = this.evaluateActionable(level, clickedPos, player, level.getBlockState(clickedPos)); // Purpur - Tool actionable options
|
||||
if (optional.isEmpty()) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
+ org.purpurmc.purpur.tool.Actionable actionable = optional.get(); // Purpur - Tool actionable options
|
||||
+ BlockState state = actionable.into().withPropertiesOf(level.getBlockState(clickedPos)); // Purpur - Tool actionable options
|
||||
ItemStack itemInHand = context.getItemInHand();
|
||||
// Paper start - EntityChangeBlockEvent
|
||||
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, clickedPos, optional.get())) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, clickedPos, state)) { // Purpur - Tool actionable options
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
// Paper end
|
||||
@@ -76,8 +78,15 @@ public class AxeItem extends Item {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, clickedPos, itemInHand);
|
||||
}
|
||||
|
||||
- level.setBlock(clickedPos, optional.get(), 11);
|
||||
- level.gameEvent(GameEvent.BLOCK_CHANGE, clickedPos, GameEvent.Context.of(player, optional.get()));
|
||||
+ // Purpur start - Tool actionable options
|
||||
+ level.setBlock(clickedPos, state, 11);
|
||||
+ actionable.drops().forEach((drop, chance) -> {
|
||||
+ if (level.random.nextDouble() < chance) {
|
||||
+ Block.popResourceFromFace(level, clickedPos, context.getClickedFace(), new ItemStack(drop));
|
||||
+ }
|
||||
+ });
|
||||
+ level.gameEvent(GameEvent.BLOCK_CHANGE, clickedPos, GameEvent.Context.of(player, state));
|
||||
+ // Purpur end - Tool actionable options
|
||||
if (player != null) {
|
||||
itemInHand.hurtAndBreak(1, player, LivingEntity.getSlotForHand(context.getHand()));
|
||||
}
|
||||
@@ -94,22 +103,24 @@ public class AxeItem extends Item {
|
||||
&& !player.isSecondaryUseActive();
|
||||
}
|
||||
|
||||
- private Optional<BlockState> evaluateNewBlockState(Level level, BlockPos pos, @Nullable Player player, BlockState state) {
|
||||
- Optional<BlockState> stripped = this.getStripped(state);
|
||||
+ private Optional<org.purpurmc.purpur.tool.Actionable> evaluateActionable(Level level, BlockPos pos, @Nullable Player player, BlockState state) { // Purpur - Tool actionable options
|
||||
+ Optional<org.purpurmc.purpur.tool.Actionable> stripped = Optional.ofNullable(level.purpurConfig.axeStrippables.get(state.getBlock())); // Purpur - Tool actionable options
|
||||
if (stripped.isPresent()) {
|
||||
- level.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ level.playSound(STRIPPABLES.containsKey(state.getBlock()) ? player : null, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - force sound
|
||||
return stripped;
|
||||
} else {
|
||||
- Optional<BlockState> previous = WeatheringCopper.getPrevious(state);
|
||||
+ Optional<org.purpurmc.purpur.tool.Actionable> previous = Optional.ofNullable(level.purpurConfig.axeWeatherables.get(state.getBlock())); // Purpur - Tool actionable options
|
||||
if (previous.isPresent()) {
|
||||
- level.playSound(player, pos, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ level.playSound(WeatheringCopper.getPrevious(state).isPresent() ? player : null, pos, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - Tool actionable options - force sound
|
||||
level.levelEvent(player, 3005, pos, 0);
|
||||
return previous;
|
||||
} else {
|
||||
- Optional<BlockState> optional = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(state.getBlock()))
|
||||
- .map(block -> block.withPropertiesOf(state));
|
||||
+ // Purpur start - Tool actionable options
|
||||
+ Optional<org.purpurmc.purpur.tool.Actionable> optional = Optional.ofNullable(level.purpurConfig.axeWaxables.get(state.getBlock()));
|
||||
+ // .map(block -> block.withPropertiesOf(state));
|
||||
+ // Purpur end - Tool actionable options
|
||||
if (optional.isPresent()) {
|
||||
- level.playSound(player, pos, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ level.playSound(HoneycombItem.WAX_OFF_BY_BLOCK.get().containsKey(state.getBlock()) ? player : null, pos, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - Tool actionable options - force sound
|
||||
level.levelEvent(player, 3004, pos, 0);
|
||||
return optional;
|
||||
} else {
|
||||
@@ -0,0 +1,44 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
|
||||
index 6db566adf2d0df1d26221eda04aa01738df6d3d2..3dbdb5c30f8af89e768016bb683a4d2c1549aa0e 100644
|
||||
--- a/net/minecraft/world/item/BlockItem.java
|
||||
+++ b/net/minecraft/world/item/BlockItem.java
|
||||
@@ -144,7 +144,16 @@ public class BlockItem extends Item {
|
||||
}
|
||||
|
||||
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level level, @Nullable Player player, ItemStack stack, BlockState state) {
|
||||
- return updateCustomBlockEntityTag(level, player, pos, stack);
|
||||
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
|
||||
+ boolean handled = updateCustomBlockEntityTag(level, player, pos, stack);
|
||||
+ if (level.purpurConfig.persistentTileEntityLore) {
|
||||
+ BlockEntity blockEntity1 = level.getBlockEntity(pos);
|
||||
+ if (blockEntity1 != null) {
|
||||
+ blockEntity1.setPersistentLore(stack.getOrDefault(DataComponents.LORE, net.minecraft.world.item.component.ItemLore.EMPTY));
|
||||
+ }
|
||||
+ }
|
||||
+ return handled;
|
||||
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -211,6 +220,7 @@ public class BlockItem extends Item {
|
||||
}
|
||||
|
||||
if (!type.onlyOpCanSetNbt() || player != null && (player.canUseGameMasterBlocks() || (player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.nbt.place")))) { // Spigot - add permission
|
||||
+ if (!(level.purpurConfig.silkTouchEnabled && blockEntity instanceof net.minecraft.world.level.block.entity.SpawnerBlockEntity && player.getBukkitEntity().hasPermission("purpur.drop.spawners"))) // Purpur - Silk touch spawners
|
||||
return customData.loadInto(blockEntity, level.registryAccess());
|
||||
}
|
||||
|
||||
@@ -252,6 +262,7 @@ public class BlockItem extends Item {
|
||||
public void onDestroyed(ItemEntity itemEntity) {
|
||||
ItemContainerContents itemContainerContents = itemEntity.getItem().set(DataComponents.CONTAINER, ItemContainerContents.EMPTY);
|
||||
if (itemContainerContents != null) {
|
||||
+ if (itemEntity.level().purpurConfig.shulkerBoxItemDropContentsWhenDestroyed && this.getBlock() instanceof ShulkerBoxBlock) // Purpur - option to disable shulker box items from dropping contents when destroyed
|
||||
ItemUtils.onContainerDestroyed(itemEntity, itemContainerContents.nonEmptyItemsCopy());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/item/HoeItem.java b/net/minecraft/world/item/HoeItem.java
|
||||
index 3bf3d4030c4da65fa386a8b8083d259a6046d15e..77a8d5d334cd93d23149afa8e58f4114412632df 100644
|
||||
--- a/net/minecraft/world/item/HoeItem.java
|
||||
+++ b/net/minecraft/world/item/HoeItem.java
|
||||
@@ -45,15 +45,25 @@ public class HoeItem extends Item {
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
Level level = context.getLevel();
|
||||
BlockPos clickedPos = context.getClickedPos();
|
||||
- Pair<Predicate<UseOnContext>, Consumer<UseOnContext>> pair = TILLABLES.get(level.getBlockState(clickedPos).getBlock());
|
||||
- if (pair == null) {
|
||||
+ // Purpur start - Tool actionable options
|
||||
+ Block clickedBlock = level.getBlockState(clickedPos).getBlock();
|
||||
+ org.purpurmc.purpur.tool.Tillable tillable = level.purpurConfig.hoeTillables.get(clickedBlock);
|
||||
+ if (tillable == null) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
- Predicate<UseOnContext> predicate = pair.getFirst();
|
||||
- Consumer<UseOnContext> consumer = pair.getSecond();
|
||||
+ Predicate<UseOnContext> predicate = tillable.condition().predicate();
|
||||
+ Consumer<UseOnContext> consumer = (ctx) -> {
|
||||
+ level.setBlock(clickedPos, tillable.into().defaultBlockState(), 11);
|
||||
+ tillable.drops().forEach((drop, chance) -> {
|
||||
+ if (level.random.nextDouble() < chance) {
|
||||
+ Block.popResourceFromFace(level, clickedPos, ctx.getClickedFace(), new ItemStack(drop));
|
||||
+ }
|
||||
+ });
|
||||
+ };
|
||||
+ // Purpur end - Tool actionable options
|
||||
if (predicate.test(context)) {
|
||||
Player player = context.getPlayer();
|
||||
- level.playSound(player, clickedPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ if (!TILLABLES.containsKey(clickedBlock)) level.playSound(null, clickedPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - Tool actionable options - force sound
|
||||
if (!level.isClientSide) {
|
||||
consumer.accept(context);
|
||||
if (player != null) {
|
||||
@@ -0,0 +1,34 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/item/SpawnEggItem.java b/net/minecraft/world/item/SpawnEggItem.java
|
||||
index 7a961e5ebbdac061f6e73e4ed07fe957ba759066..d48c1dedbd39770ccf3c9c3ff3351b391601cd77 100644
|
||||
--- a/net/minecraft/world/item/SpawnEggItem.java
|
||||
+++ b/net/minecraft/world/item/SpawnEggItem.java
|
||||
@@ -57,6 +57,23 @@ public class SpawnEggItem extends Item {
|
||||
if (level.getBlockEntity(clickedPos) instanceof Spawner spawner) {
|
||||
if (level.paperConfig().entities.spawning.disableMobSpawnerSpawnEggTransformation) return InteractionResult.FAIL; // Paper - Allow disabling mob spawner spawn egg transformation
|
||||
EntityType<?> type = this.getType(level.registryAccess(), itemInHand);
|
||||
+ // Purpur start - PlayerSetSpawnerTypeWithEggEvent
|
||||
+ if (spawner instanceof net.minecraft.world.level.block.entity.SpawnerBlockEntity) {
|
||||
+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(clickedPos.getX(), clickedPos.getY(), clickedPos.getZ());
|
||||
+ org.purpurmc.purpur.event.PlayerSetSpawnerTypeWithEggEvent event = new org.purpurmc.purpur.event.PlayerSetSpawnerTypeWithEggEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), bukkitBlock, (org.bukkit.block.CreatureSpawner) bukkitBlock.getState(), org.bukkit.entity.EntityType.fromName(type.getName()));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ type = EntityType.getFromBukkitType(event.getEntityType());
|
||||
+ } else if (spawner instanceof net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity) {
|
||||
+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(clickedPos.getX(), clickedPos.getY(), clickedPos.getZ());
|
||||
+ org.purpurmc.purpur.event.PlayerSetTrialSpawnerTypeWithEggEvent event = new org.purpurmc.purpur.event.PlayerSetTrialSpawnerTypeWithEggEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), bukkitBlock, (org.bukkit.block.TrialSpawner) bukkitBlock.getState(), org.bukkit.entity.EntityType.fromName(type.getName()));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ type = EntityType.getFromBukkitType(event.getEntityType());
|
||||
+ }
|
||||
+ // Purpur end - PlayerSetSpawnerTypeWithEggEvent
|
||||
spawner.setEntityId(type, level.getRandom());
|
||||
level.sendBlockUpdated(clickedPos, blockState, blockState, 3);
|
||||
level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos);
|
||||
@@ -0,0 +1,96 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
|
||||
index be6f37f91569c659c609e5e8d38671ca86f8cd95..d023c985344807db2180665a15d282fa50754299 100644
|
||||
--- a/net/minecraft/world/level/block/Block.java
|
||||
+++ b/net/minecraft/world/level/block/Block.java
|
||||
@@ -99,6 +99,10 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
public static final int UPDATE_LIMIT = 512;
|
||||
protected final StateDefinition<Block, BlockState> stateDefinition;
|
||||
private BlockState defaultBlockState;
|
||||
+ // Purpur start - Configurable block fall damage modifiers
|
||||
+ public float fallDamageMultiplier = 1.0F;
|
||||
+ public float fallDistanceMultiplier = 1.0F;
|
||||
+ // Purpur end - Configurable block fall damage modifiers
|
||||
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
|
||||
public final boolean isDestroyable() {
|
||||
return io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits ||
|
||||
@@ -345,7 +349,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
event.setExpToDrop(block.getExpDrop(state, serverLevel, pos, net.minecraft.world.item.ItemStack.EMPTY, true)); // Paper - Properly handle xp dropping
|
||||
event.callEvent();
|
||||
for (org.bukkit.inventory.ItemStack drop : event.getDrops()) {
|
||||
- popResource(serverLevel, pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop));
|
||||
+ popResource(serverLevel, pos, applyLoreFromTile(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop), blockEntity)); // Purpur - Persistent BlockEntity Lore and DisplayName
|
||||
}
|
||||
state.spawnAfterBreak(serverLevel, pos, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping
|
||||
block.popExperience(serverLevel, pos, event.getExpToDrop()); // Paper - Properly handle xp dropping
|
||||
@@ -363,7 +367,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
|
||||
public static void dropResources(BlockState state, LevelAccessor level, BlockPos pos, @Nullable BlockEntity blockEntity) {
|
||||
if (level instanceof ServerLevel) {
|
||||
- getDrops(state, (ServerLevel)level, pos, blockEntity).forEach(stack -> popResource((ServerLevel)level, pos, stack));
|
||||
+ getDrops(state, (ServerLevel)level, pos, blockEntity).forEach(stack -> popResource((ServerLevel)level, pos, applyLoreFromTile(stack, blockEntity))); // Purpur - Persistent BlockEntity Lore and DisplayName
|
||||
state.spawnAfterBreak((ServerLevel)level, pos, ItemStack.EMPTY, true);
|
||||
}
|
||||
}
|
||||
@@ -375,11 +379,30 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool, boolean dropExperience) {
|
||||
// Paper end - Properly handle xp dropping
|
||||
if (level instanceof ServerLevel) {
|
||||
- getDrops(state, (ServerLevel)level, pos, blockEntity, entity, tool).forEach(stack -> popResource(level, pos, stack));
|
||||
+ getDrops(state, (ServerLevel)level, pos, blockEntity, entity, tool).forEach(stack -> popResource(level, pos, applyLoreFromTile(stack, blockEntity))); // Purpur - Persistent BlockEntity Lore and DisplayName
|
||||
state.spawnAfterBreak((ServerLevel)level, pos, tool, dropExperience); // Paper - Properly handle xp dropping
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
|
||||
+ private static ItemStack applyLoreFromTile(ItemStack stack, @Nullable BlockEntity blockEntity) {
|
||||
+ if (stack.getItem() instanceof BlockItem) {
|
||||
+ if (blockEntity != null && blockEntity.getLevel() instanceof ServerLevel) {
|
||||
+ net.minecraft.world.item.component.ItemLore lore = blockEntity.getPersistentLore();
|
||||
+ net.minecraft.core.component.DataComponentPatch.Builder builder = net.minecraft.core.component.DataComponentPatch.builder();
|
||||
+ if (blockEntity.getLevel().purpurConfig.persistentTileEntityLore && lore != null) {
|
||||
+ builder.set(net.minecraft.core.component.DataComponents.LORE, lore);
|
||||
+ }
|
||||
+ if (!blockEntity.getLevel().purpurConfig.persistentTileEntityDisplayName) {
|
||||
+ builder.remove(net.minecraft.core.component.DataComponents.CUSTOM_NAME);
|
||||
+ }
|
||||
+ stack.applyComponents(builder.build());
|
||||
+ }
|
||||
+ }
|
||||
+ return stack;
|
||||
+ }
|
||||
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
|
||||
+
|
||||
public static void popResource(Level level, BlockPos pos, ItemStack stack) {
|
||||
double d = EntityType.ITEM.getHeight() / 2.0;
|
||||
double d1 = pos.getX() + 0.5 + Mth.nextDouble(level.random, -0.25, 0.25);
|
||||
@@ -460,7 +483,15 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
}
|
||||
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
+ this.placer = placer; // Purpur - Store placer on Block when placed
|
||||
+ }
|
||||
+
|
||||
+ // Purpur start - Store placer on Block when placed
|
||||
+ @Nullable protected LivingEntity placer = null;
|
||||
+ public void forgetPlacer() {
|
||||
+ this.placer = null;
|
||||
}
|
||||
+ // Purpur end - Store placer on Block when placed
|
||||
|
||||
public boolean isPossibleToRespawnInThis(BlockState state) {
|
||||
return !state.isSolid() && !state.liquid();
|
||||
@@ -471,7 +502,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
}
|
||||
|
||||
public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) {
|
||||
- entity.causeFallDamage(fallDistance, 1.0F, entity.damageSources().fall());
|
||||
+ entity.causeFallDamage(fallDistance * fallDistanceMultiplier, fallDamageMultiplier, entity.damageSources().fall()); // Purpur - Configurable block fall damage modifiers
|
||||
}
|
||||
|
||||
public void updateEntityMovementAfterFallOn(BlockGetter level, Entity entity) {
|
||||
@@ -0,0 +1,44 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/CarvedPumpkinBlock.java b/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
||||
index 7cdf16c7216878350537b5331081cb30f44d6dbb..a4854370dfdcbc7ec4c27975e4feb69d4cb48a11 100644
|
||||
--- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
||||
+++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
||||
@@ -64,7 +64,7 @@ public class CarvedPumpkinBlock extends HorizontalDirectionalBlock {
|
||||
if (blockPatternMatch != null) {
|
||||
SnowGolem snowGolem = EntityType.SNOW_GOLEM.create(level, EntitySpawnReason.TRIGGERED);
|
||||
if (snowGolem != null) {
|
||||
- spawnGolemInWorld(level, blockPatternMatch, snowGolem, blockPatternMatch.getBlock(0, 2, 0).getPos());
|
||||
+ spawnGolemInWorld(level, blockPatternMatch, snowGolem, blockPatternMatch.getBlock(0, 2, 0).getPos(), this.placer); // Purpur - Summoner API
|
||||
}
|
||||
} else {
|
||||
BlockPattern.BlockPatternMatch blockPatternMatch1 = this.getOrCreateIronGolemFull().find(level, pos);
|
||||
@@ -72,13 +72,23 @@ public class CarvedPumpkinBlock extends HorizontalDirectionalBlock {
|
||||
IronGolem ironGolem = EntityType.IRON_GOLEM.create(level, EntitySpawnReason.TRIGGERED);
|
||||
if (ironGolem != null) {
|
||||
ironGolem.setPlayerCreated(true);
|
||||
- spawnGolemInWorld(level, blockPatternMatch1, ironGolem, blockPatternMatch1.getBlock(1, 2, 0).getPos());
|
||||
+ spawnGolemInWorld(level, blockPatternMatch1, ironGolem, blockPatternMatch1.getBlock(1, 2, 0).getPos(), this.placer); // Purpur - Summoner API
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) {
|
||||
+ // Purpur start - Summoner API
|
||||
+ spawnGolemInWorld(level, patternMatch, golem, pos, null);
|
||||
+ }
|
||||
+ private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos, net.minecraft.world.entity.LivingEntity placer) {
|
||||
+ if (golem instanceof SnowGolem snowGolem) {
|
||||
+ snowGolem.setSummoner(placer == null ? null : placer.getUUID());
|
||||
+ } else if (golem instanceof IronGolem ironGolem) {
|
||||
+ ironGolem.setSummoner(placer == null ? null : placer.getUUID());
|
||||
+ }
|
||||
+ // Purpur end - Summoner API
|
||||
// clearPatternBlocks(level, patternMatch); // Paper - moved down
|
||||
golem.snapTo(pos.getX() + 0.5, pos.getY() + 0.05, pos.getZ() + 0.5, 0.0F, 0.0F);
|
||||
// Paper start
|
||||
@@ -0,0 +1,74 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java
|
||||
index a647d76d365a60b95a3eb7927ac426bf70d417f3..3eb11df5d14ec63911be630ca99d8d9903723f9b 100644
|
||||
--- a/net/minecraft/world/level/block/ComposterBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ComposterBlock.java
|
||||
@@ -250,17 +250,27 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
) {
|
||||
int levelValue = state.getValue(LEVEL);
|
||||
if (levelValue < 8 && COMPOSTABLES.containsKey(stack.getItem())) {
|
||||
- if (levelValue < 7 && !level.isClientSide) {
|
||||
- BlockState blockState = addItem(player, state, level, pos, stack);
|
||||
- // Paper start - handle cancelled events
|
||||
- if (blockState == null) {
|
||||
- return InteractionResult.PASS;
|
||||
- }
|
||||
- // Paper end
|
||||
- level.levelEvent(1500, pos, state != blockState ? 1 : 0);
|
||||
- player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
|
||||
- stack.consume(1, player);
|
||||
+ // Purpur start - sneak to bulk process composter
|
||||
+ BlockState newState = process(levelValue, player, state, level, pos, stack);
|
||||
+ if (newState == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ if (level.purpurConfig.composterBulkProcess && player.isShiftKeyDown() && newState != state) {
|
||||
+ BlockState oldState;
|
||||
+ int oldCount, newCount, oldLevel, newLevel;
|
||||
+ do {
|
||||
+ oldState = newState;
|
||||
+ oldCount = stack.getCount();
|
||||
+ oldLevel = oldState.getValue(ComposterBlock.LEVEL);
|
||||
+ newState = process(oldLevel, player, oldState, level, pos, stack);
|
||||
+ if (newState == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ newCount = stack.getCount();
|
||||
+ newLevel = newState.getValue(ComposterBlock.LEVEL);
|
||||
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
|
||||
}
|
||||
+ // Purpur end - Sneak to bulk process composter
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
@@ -268,6 +278,25 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - sneak to bulk process composter
|
||||
+ private static @Nullable BlockState process(int levelValue, Player player, BlockState state, Level level, BlockPos pos, ItemStack stack) {
|
||||
+ if (levelValue < 7 && !level.isClientSide) {
|
||||
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, level, pos, stack);
|
||||
+ // Paper start - handle cancelled events
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
+ level.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
||||
+ player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
|
||||
+ stack.consume(1, player);
|
||||
+ return iblockdata1;
|
||||
+ }
|
||||
+ return state;
|
||||
+ }
|
||||
+ // Purpur end - Sneak to bulk process composter
|
||||
+
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
||||
int levelValue = state.getValue(LEVEL);
|
||||
@@ -0,0 +1,64 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
index 91f7ee163107d846e7f6a5783be6eff96e783886..b1b49fa83794f4237994e9b985816ddf6d20b7e9 100644
|
||||
--- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
@@ -75,7 +75,7 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
"leash",
|
||||
"UUID"
|
||||
);
|
||||
- public static final int MAX_OCCUPANTS = 3;
|
||||
+ public static final int MAX_OCCUPANTS = org.purpurmc.purpur.PurpurConfig.beeInsideBeeHive; // Purpur - Config to change max number of bees
|
||||
private static final int MIN_TICKS_BEFORE_REENTERING_HIVE = 400;
|
||||
private static final int MIN_OCCUPATION_TICKS_NECTAR = 2400;
|
||||
public static final int MIN_OCCUPATION_TICKS_NECTARLESS = 600;
|
||||
@@ -150,11 +150,33 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
return list;
|
||||
}
|
||||
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<Entity> releaseBee(BlockState iblockdata, BeehiveBlockEntity.BeeData data, BeehiveBlockEntity.BeeReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
||||
+ List<Entity> list = Lists.newArrayList();
|
||||
+
|
||||
+ BeehiveBlockEntity.releaseOccupant(this.level, this.worldPosition, iblockdata, data.occupant, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
|
||||
+
|
||||
+ if (!list.isEmpty()) {
|
||||
+ stored.remove(data);
|
||||
+
|
||||
+ super.setChanged();
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
@VisibleForDebug
|
||||
public int getOccupantCount() {
|
||||
return this.stored.size();
|
||||
}
|
||||
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<BeeData> getStored() {
|
||||
+ return stored;
|
||||
+ }
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
// Paper start - Add EntityBlockStorage clearEntities
|
||||
public void clearBees() {
|
||||
this.stored.clear();
|
||||
@@ -392,8 +414,8 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
return this.stored.stream().map(BeehiveBlockEntity.BeeData::toOccupant).toList();
|
||||
}
|
||||
|
||||
- static class BeeData {
|
||||
- private final BeehiveBlockEntity.Occupant occupant;
|
||||
+ public static class BeeData { // Purpur - make public - Stored Bee API
|
||||
+ public final BeehiveBlockEntity.Occupant occupant; // Purpur - make public - Stored Bee API
|
||||
private int exitTickCounter; // Paper - Fix bees aging inside hives; separate counter for checking if bee should exit to reduce exit attempts
|
||||
private int ticksInHive;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
From 1e4693c6129676cacc2e29a157b5a69107c78543 Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 06:37:42 -0700
|
||||
Subject: [PATCH] purpur File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
index 0e87d20639c382be2221d73c7498480d21ebeafb..3ea9fe4c936f024c15a6bba6e7c5d960a3def1f9 100644
|
||||
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
@@ -151,7 +151,7 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
BlockPos blockPos1 = pos.offset(i, i1, i2x);
|
||||
BlockState blockState = level.getBlockState(blockPos1);
|
||||
|
||||
- for (Block block : VALID_BLOCKS) {
|
||||
+ for (Block block : level.purpurConfig.conduitBlocks) { // Purpur - Conduit behavior configuration
|
||||
if (blockState.is(block)) {
|
||||
positions.add(blockPos1);
|
||||
}
|
||||
@@ -166,13 +166,13 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
|
||||
private static void applyEffects(Level level, BlockPos pos, List<BlockPos> positions) {
|
||||
// CraftBukkit start
|
||||
- ConduitBlockEntity.applyEffects(level, pos, ConduitBlockEntity.getRange(positions));
|
||||
+ ConduitBlockEntity.applyEffects(level, pos, ConduitBlockEntity.getRange(positions, level)); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
- public static int getRange(List<BlockPos> positions) {
|
||||
+ public static int getRange(List<BlockPos> positions, Level level) { // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit end
|
||||
int size = positions.size();
|
||||
- int i = size / 7 * 16;
|
||||
+ int i = size / 7 * level.purpurConfig.conduitDistance; // Purpur - Conduit behavior configuration
|
||||
// CraftBukkit start
|
||||
return i;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
EntityReference<LivingEntity> entityReference = updateDestroyTarget(blockEntity.destroyTarget, level, pos, canDestroy);
|
||||
LivingEntity livingEntity = EntityReference.get(entityReference, level, LivingEntity.class);
|
||||
if (damageTarget && livingEntity != null) { // CraftBukkit
|
||||
- if (livingEntity.hurtServer(level, level.damageSources().magic().eventBlockDamager(level, pos), 4.0F)) // CraftBukkit - move up
|
||||
+ if (livingEntity.hurtServer(level, level.damageSources().magic().eventBlockDamager(level, pos), level.purpurConfig.conduitDamageAmount)) // CraftBukkit - move up // Purpur - Conduit behavior configuration
|
||||
level.playSound(
|
||||
null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F
|
||||
);
|
||||
@@ -224,20 +224,26 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
return selectNewTarget(level, pos);
|
||||
} else {
|
||||
LivingEntity livingEntity = EntityReference.get(destroyTarget, level, LivingEntity.class);
|
||||
- return livingEntity != null && livingEntity.isAlive() && pos.closerThan(livingEntity.blockPosition(), 8.0) ? destroyTarget : null;
|
||||
+ return livingEntity != null && livingEntity.isAlive() && pos.closerThan(livingEntity.blockPosition(), level.purpurConfig.conduitDamageDistance) ? destroyTarget : null; // Purpur - Conduit behavior configuration
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static EntityReference<LivingEntity> selectNewTarget(ServerLevel level, BlockPos pos) {
|
||||
List<LivingEntity> entitiesOfClass = level.getEntitiesOfClass(
|
||||
- LivingEntity.class, getDestroyRangeAABB(pos), livingEntity -> livingEntity instanceof Enemy && livingEntity.isInWaterOrRain()
|
||||
+ LivingEntity.class, getDestroyRangeAABB(pos, level), livingEntity -> livingEntity instanceof Enemy && livingEntity.isInWaterOrRain() // Purpur - Conduit behavior configuration
|
||||
);
|
||||
return entitiesOfClass.isEmpty() ? null : new EntityReference<>(Util.getRandom(entitiesOfClass, level.random));
|
||||
}
|
||||
|
||||
public static AABB getDestroyRangeAABB(BlockPos pos) {
|
||||
- return new AABB(pos).inflate(8.0);
|
||||
+ // Purpur start - Conduit behavior configuration
|
||||
+ return getDestroyRangeAABB(pos, null);
|
||||
+ }
|
||||
+
|
||||
+ private static AABB getDestroyRangeAABB(BlockPos pos, Level level) {
|
||||
+ // Purpur end - Conduit behavior configuration
|
||||
+ return new AABB(pos).inflate(level == null ? 8.0 : level.purpurConfig.conduitDamageDistance); // Purpur - Conduit behavior configuration
|
||||
}
|
||||
|
||||
private static void animationTick(Level level, BlockPos pos, List<BlockPos> positions, @Nullable Entity entity, int tickCount) {
|
||||
Reference in New Issue
Block a user