apply the rest of the minecraft file patches \o/

This commit is contained in:
granny
2025-06-01 14:33:08 -07:00
parent 994dd4f476
commit 89ee2e0c0f
33 changed files with 484 additions and 689 deletions

View File

@@ -0,0 +1,40 @@
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -73,7 +_,7 @@
) {
this.level = level;
this.source = source;
- this.radius = (float) Math.max(radius, 0.0); // CraftBukkit - clamp bad values
+ this.radius = (float) (level == null || level.purpurConfig.explosionClampRadius ? Math.max(radius, 0.0) : radius); // CraftBukkit - clamp bad values // Purpur - Config to remove explosion radius clamp
this.center = center;
this.fire = fire;
this.blockInteraction = blockInteraction;
@@ -356,10 +_,27 @@
public void explode() {
// CraftBukkit start
- if (this.radius < 0.1F) {
+ if ((this.level == null || this.level.purpurConfig.explosionClampRadius) && this.radius < 0.1F) { // Purpur - Config to remove explosion radius clamp
return;
}
// CraftBukkit end
+ // Purpur start - add PreExplodeEvents
+ if (this.source != null) {
+ Location location = new Location(this.level.getWorld(), this.center.x, this.center.y, this.center.z);
+ if(!new org.purpurmc.purpur.event.entity.PreEntityExplodeEvent(this.source.getBukkitEntity(), location, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, org.bukkit.craftbukkit.CraftExplosionResult.toExplosionResult(getBlockInteraction())).callEvent()) {
+ this.wasCanceled = true;
+ return;
+ }
+ } else {
+ Location location = new Location(this.level.getWorld(), this.center.x, this.center.y, this.center.z);
+ org.bukkit.block.Block block = location.getBlock();
+ org.bukkit.block.BlockState blockState = (this.damageSource.causingBlockSnapshot() != null) ? this.damageSource.causingBlockSnapshot() : block.getState();
+ if(!new org.purpurmc.purpur.event.PreBlockExplodeEvent(location.getBlock(), this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F, blockState, org.bukkit.craftbukkit.CraftExplosionResult.toExplosionResult(getBlockInteraction())).callEvent()) {
+ this.wasCanceled = true;
+ return;
+ }
+ }
+ // Purpur end - Add PreExplodeEvents
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
List<BlockPos> list = this.calculateExplodedPositions();
this.hurtEntities();

View File

@@ -0,0 +1,43 @@
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -104,6 +_,10 @@
input.read("PublicBukkitValues", CompoundTag.CODEC)
.ifPresent(this.persistentDataContainer::putAll);
// Paper end - read persistent data container
+
+
+ this.persistentLore = tag.read("Purpur.persistentLore", net.minecraft.world.item.component.ItemLore.CODEC).orElse(null); // Purpur - Persistent BlockEntity Lore and DisplayName
+
}
public final void loadWithComponents(ValueInput input) {
@@ -116,6 +_,11 @@
}
protected void saveAdditional(ValueOutput output) {
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
+ if (this.persistentLore != null) {
+ output.store("Purpur.persistentLore", net.minecraft.world.item.component.ItemLore.CODEC, this.persistentLore);
+ }
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
}
public final CompoundTag saveWithFullMetadata(HolderLookup.Provider registries) {
@@ -400,4 +_,17 @@
return this.blockEntity.getNameForReporting() + "@" + this.blockEntity.getBlockPos();
}
}
+
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
+ @Nullable
+ private net.minecraft.world.item.component.ItemLore persistentLore = null;
+
+ public void setPersistentLore(net.minecraft.world.item.component.ItemLore lore) {
+ this.persistentLore = lore;
+ }
+
+ public @org.jetbrains.annotations.Nullable net.minecraft.world.item.component.ItemLore getPersistentLore() {
+ return this.persistentLore;
+ }
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
}

View File

@@ -0,0 +1,67 @@
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
@@ -151,7 +_,7 @@
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 +_,13 @@
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 +_,7 @@
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(), 4.0F)) // CraftBukkit - move up
+ if (livingEntity.hurtServer(level, level.damageSources().magic(), 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 +_,26 @@
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) {

View File

@@ -0,0 +1,40 @@
--- a/net/minecraft/world/level/block/entity/EnchantingTableBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/EnchantingTableBlockEntity.java
@@ -30,6 +_,7 @@
private static final RandomSource RANDOM = RandomSource.create();
@Nullable
private Component name;
+ private int lapis = 0; // Purpur - Enchantment Table Persists Lapis
public EnchantingTableBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.ENCHANTING_TABLE, pos, state);
@@ -39,12 +_,14 @@
protected void saveAdditional(ValueOutput output) {
super.saveAdditional(output);
output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name);
+ output.putInt("Purpur.Lapis", this.lapis); // Purpur - Enchantment Table Persists Lapis
}
@Override
protected void loadAdditional(ValueInput input) {
super.loadAdditional(input);
this.name = parseCustomNameSafe(input, "CustomName");
+ this.lapis = input.getIntOr("Purpur.Lapis", 0); // Purpur - Enchantment Table Persists Lapis
}
public static void bookAnimationTick(Level level, BlockPos pos, BlockState state, EnchantingTableBlockEntity enchantingTable) {
@@ -136,4 +_,14 @@
public void removeComponentsFromTag(ValueOutput output) {
output.discard("CustomName");
}
+
+ // Purpur start - Enchantment Table Persists Lapis
+ public int getLapis() {
+ return this.lapis;
+ }
+
+ public void setLapis(int lapis) {
+ this.lapis = lapis;
+ }
+ // Purpur end - Enchantment Table Persists Lapis
}

View File

@@ -0,0 +1,10 @@
--- a/net/minecraft/world/level/chunk/storage/EntityStorage.java
+++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java
@@ -97,6 +_,7 @@
ListTag listTag = new ListTag();
entities.getEntities().forEach(entity -> {
TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector.forChild(entity.problemPath()), entity.registryAccess());
+ if (!entity.canSaveToDisk()) return; // Purpur - Add canSaveToDisk to Entity
if (entity.save(tagValueOutput)) {
CompoundTag compoundTag1 = tagValueOutput.buildResult();
listTag.add(compoundTag1);