Couple of block entities

This commit is contained in:
Bjarne Koll
2025-05-28 13:57:49 +02:00
parent b745ab65e6
commit 40c8d4f900
13 changed files with 268 additions and 355 deletions

View File

@@ -1,70 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
index 0b5e7dd0987b9892f3cddb02930254fc559b64d0..2f07a23a6151a4dfb28ddc0ab38ec2abefcdd27c 100644
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
@@ -165,8 +165,20 @@ 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));
+ }
+
+ public static int getRange(List<BlockPos> positions) {
+ // CraftBukkit end
int size = positions.size();
int i = size / 7 * 16;
+ // CraftBukkit start
+ return i;
+ }
+
+ private static void applyEffects(Level level, BlockPos pos, int i) { // i = effect range in blocks
+ // CraftBukkit end
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
@@ -175,13 +187,19 @@ public class ConduitBlockEntity extends BlockEntity {
if (!entitiesOfClass.isEmpty()) {
for (Player player : entitiesOfClass) {
if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) {
- player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+ player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
}
}
}
}
private static void updateDestroyTarget(Level level, BlockPos pos, BlockState state, List<BlockPos> positions, ConduitBlockEntity blockEntity) {
+ // CraftBukkit start - add "damageTarget" boolean
+ ConduitBlockEntity.updateDestroyTarget(level, pos, state, positions, blockEntity, true);
+ }
+
+ public static void updateDestroyTarget(Level level, BlockPos pos, BlockState state, List<BlockPos> positions, ConduitBlockEntity blockEntity, boolean damageTarget) {
+ // CraftBukkit end
LivingEntity livingEntity = blockEntity.destroyTarget;
int size = positions.size();
if (size < 42) {
@@ -200,7 +218,8 @@ public class ConduitBlockEntity extends BlockEntity {
blockEntity.destroyTarget = null;
}
- if (blockEntity.destroyTarget != null) {
+ if (damageTarget && blockEntity.destroyTarget != null) { // CraftBukkit
+ if (blockEntity.destroyTarget.hurtServer((net.minecraft.server.level.ServerLevel) level, level.damageSources().magic().eventBlockDamager(level, pos), 4.0F)) // CraftBukkit
level.playSound(
null,
blockEntity.destroyTarget.getX(),
@@ -211,7 +230,6 @@ public class ConduitBlockEntity extends BlockEntity {
1.0F,
1.0F
);
- blockEntity.destroyTarget.hurt(level.damageSources().magic(), 4.0F);
}
if (livingEntity != blockEntity.destroyTarget) {

View File

@@ -1,50 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
index 431a9a4e6eef97579e3bb58d4c0dbff7e9c410dd..26d2205fe7c1322f52e7d162e1be9dc23349f3b6 100644
--- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
@@ -24,6 +24,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
private final VibrationSystem.Listener vibrationListener;
private final VibrationSystem.User vibrationUser;
public int lastVibrationFrequency = 0;
+ @Nullable public Integer rangeOverride = null; // Paper - Configurable sculk sensor listener range
protected SculkSensorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) {
super(type, pos, blockState);
@@ -46,15 +47,23 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
this.lastVibrationFrequency = tag.getIntOr("last_vibration_frequency", 0);
RegistryOps<Tag> registryOps = registries.createSerializationContext(NbtOps.INSTANCE);
this.vibrationData = tag.read("listener", VibrationSystem.Data.CODEC, registryOps).orElseGet(VibrationSystem.Data::new);
+ this.rangeOverride = tag.getInt(PAPER_LISTENER_RANGE_NBT_KEY).orElse(null); // Paper start - Configurable sculk sensor listener range
}
+ protected static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper - Configurable sculk sensor listener range
@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
tag.putInt("last_vibration_frequency", this.lastVibrationFrequency);
RegistryOps<Tag> registryOps = registries.createSerializationContext(NbtOps.INSTANCE);
tag.store("listener", VibrationSystem.Data.CODEC, registryOps, this.vibrationData);
+ this.saveRangeOverride(tag); // Paper - Configurable sculk sensor listener range
}
+ // Paper start - Configurable sculk sensor listener range
+ protected void saveRangeOverride(CompoundTag tag) {
+ if (this.rangeOverride != null && this.rangeOverride != VibrationUser.LISTENER_RANGE) tag.putInt(PAPER_LISTENER_RANGE_NBT_KEY, this.rangeOverride); // only save if it's different from the default
+ }
+ // Paper end - Configurable sculk sensor listener range
@Override
public VibrationSystem.Data getVibrationData() {
@@ -91,6 +100,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList
@Override
public int getListenerRadius() {
+ if (SculkSensorBlockEntity.this.rangeOverride != null) return SculkSensorBlockEntity.this.rangeOverride; // Paper - Configurable sculk sensor listener range
return 8;
}

View File

@@ -1,27 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java
index 01698814938eda15b8cf66e271aa42a4b272deac..4ec8b523bce215454045e2c082a09e6b22afa37b 100644
--- a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java
@@ -157,6 +157,7 @@ public class TestInstanceBlockEntity extends BlockEntity implements BeaconBeamOw
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
+ super.loadAdditional(tag, registries); // Paper - load the PDC
Tag tag1 = tag.get("data");
if (tag1 != null) {
TestInstanceBlockEntity.Data.CODEC.parse(NbtOps.INSTANCE, tag1).ifSuccess(this::set);
@@ -320,7 +321,7 @@ public class TestInstanceBlockEntity extends BlockEntity implements BeaconBeamOw
}
private void removeEntities() {
- this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach(Entity::discard);
+ this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach((entity) -> entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper
}
private void forceLoadChunks() {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe567d6828 100644
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -104,12 +104,50 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -104,11 +_,49 @@
};
public final Reference2IntOpenHashMap<ResourceKey<Recipe<?>>> recipesUsed = new Reference2IntOpenHashMap<>();
private final RecipeManager.CachedCheck<SingleRecipeInput, ? extends AbstractCookingRecipe> quickCheck;
@@ -18,9 +10,10 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
protected AbstractFurnaceBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState, RecipeType<? extends AbstractCookingRecipe> recipeType) {
super(type, pos, blockState);
this.quickCheck = RecipeManager.createCheck(recipeType);
- }
+ this.recipeType = recipeType; // Paper - cook speed multiplier API
}
+ }
+
+ // CraftBukkit start - add fields and methods
+ private int maxStack = MAX_STACK;
+ public List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
@@ -55,27 +48,26 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
+ this.maxStack = size;
+ }
+ // CraftBukkit end
+
private boolean isLit() {
return this.litTimeRemaining > 0;
}
@@ -125,6 +163,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
this.litTotalTime = tag.getShortOr("lit_total_time", (short)0);
@@ -125,6 +_,7 @@
this.litTotalTime = input.getShortOr("lit_total_time", (short)0);
this.recipesUsed.clear();
this.recipesUsed.putAll(tag.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of()));
+ this.cookSpeedMultiplier = tag.getDoubleOr("Paper.CookSpeedMultiplier", 1); // Paper - cook speed multiplier API
this.recipesUsed.putAll(input.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of()));
+ this.cookSpeedMultiplier = input.getDoubleOr("Paper.CookSpeedMultiplier", 1); // Paper - cook speed multiplier API
}
@Override
@@ -134,6 +173,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
tag.putShort("cooking_total_time", (short)this.cookingTotalTime);
tag.putShort("lit_time_remaining", (short)this.litTimeRemaining);
tag.putShort("lit_total_time", (short)this.litTotalTime);
+ tag.putDouble("Paper.CookSpeedMultiplier", this.cookSpeedMultiplier); // Paper - cook speed multiplier API
ContainerHelper.saveAllItems(tag, this.items, registries);
tag.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed);
@@ -134,6 +_,7 @@
output.putShort("cooking_total_time", (short)this.cookingTotalTime);
output.putShort("lit_time_remaining", (short)this.litTimeRemaining);
output.putShort("lit_total_time", (short)this.litTotalTime);
+ output.putDouble("Paper.CookSpeedMultiplier", this.cookSpeedMultiplier); // Paper - cook speed multiplier API
ContainerHelper.saveAllItems(output, this.items);
output.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed);
}
@@ -160,11 +200,22 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -160,11 +_,22 @@
int maxStackSize = furnace.getMaxStackSize();
if (!furnace.isLit() && canBurn(level.registryAccess(), recipeHolder, singleRecipeInput, furnace.items, maxStackSize)) {
@@ -101,7 +93,7 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
Item item = itemStack.getItem();
itemStack.shrink(1);
if (itemStack.isEmpty()) {
@@ -175,11 +226,28 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -175,11 +_,28 @@
}
if (furnace.isLit() && canBurn(level.registryAccess(), recipeHolder, singleRecipeInput, furnace.items, maxStackSize)) {
@@ -133,7 +125,7 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
furnace.setRecipeUsed(recipeHolder);
}
@@ -233,17 +301,47 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -233,17 +_,47 @@
@Nullable RecipeHolder<? extends AbstractCookingRecipe> recipe,
SingleRecipeInput recipeInput,
NonNullList<ItemStack> items,
@@ -185,7 +177,7 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
if (itemStack.is(Blocks.WET_SPONGE.asItem()) && !items.get(1).isEmpty() && items.get(1).is(Items.BUCKET)) {
items.set(1, new ItemStack(Items.WATER_BUCKET));
@@ -260,9 +358,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -260,9 +_,16 @@
return fuelValues.burnDuration(stack);
}
@@ -204,7 +196,7 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
}
@Override
@@ -306,7 +411,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -306,7 +_,7 @@
this.items.set(index, stack);
stack.limitSize(this.getMaxStackSize(stack));
if (index == 0 && !flag && this.level instanceof ServerLevel serverLevel) {
@@ -213,18 +205,18 @@ index 94a12d41fe7831c0a0723aa5747daa6832f5487b..c5b3b5e5f621f8db152aa190374ae0fe
this.cookingTimer = 0;
this.setChanged();
}
@@ -342,8 +447,8 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -342,8 +_,8 @@
public void awardUsedRecipes(Player player, List<ItemStack> items) {
}
- public void awardUsedRecipesAndPopExperience(ServerPlayer player) {
- List<RecipeHolder<?>> recipesToAwardAndPopExperience = this.getRecipesToAwardAndPopExperience(player.serverLevel(), player.position());
- List<RecipeHolder<?>> recipesToAwardAndPopExperience = this.getRecipesToAwardAndPopExperience(player.level(), player.position());
+ public void awardUsedRecipesAndPopExperience(ServerPlayer player, ItemStack itemstack, int amount) { // CraftBukkit
+ List<RecipeHolder<?>> recipesToAwardAndPopExperience = this.getRecipesToAwardAndPopExperience(player.serverLevel(), player.position(), this.worldPosition, player, itemstack, amount); // CraftBukkit - overload for exp spawn events
+ List<RecipeHolder<?>> recipesToAwardAndPopExperience = this.getRecipesToAwardAndPopExperience(player.level(), player.position(), this.worldPosition, player, itemstack, amount); // CraftBukkit - overload for exp spawn events
player.awardRecipes(recipesToAwardAndPopExperience);
for (RecipeHolder<?> recipeHolder : recipesToAwardAndPopExperience) {
@@ -356,30 +461,60 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -356,30 +_,60 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(ServerLevel level, Vec3 popVec) {

View File

@@ -1,32 +1,24 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/BannerBlockEntity.java b/net/minecraft/world/level/block/entity/BannerBlockEntity.java
index b61584c533ccb8340c6bd8ad0dbfc3a68600e6cc..8d409e6e768ef6294f41684bc6549b638ac1d7bc 100644
--- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java
@@ -52,7 +52,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.saveAdditional(tag, registries);
RegistryOps<Tag> registryOps = registries.createSerializationContext(NbtOps.INSTANCE);
@@ -50,7 +_,7 @@
@Override
protected void saveAdditional(ValueOutput output) {
super.saveAdditional(output);
- if (!this.patterns.equals(BannerPatternLayers.EMPTY)) {
+ if (!this.patterns.equals(BannerPatternLayers.EMPTY) || serialisingForNetwork.get()) { // Paper - always send patterns to client
tag.store("patterns", BannerPatternLayers.CODEC, registryOps, this.patterns);
output.store("patterns", BannerPatternLayers.CODEC, this.patterns);
}
@@ -64,7 +64,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
super.loadAdditional(tag, registries);
this.name = parseCustomNameSafe(tag.get("CustomName"), registries);
RegistryOps<Tag> registryOps = registries.createSerializationContext(NbtOps.INSTANCE);
- this.patterns = tag.read("patterns", BannerPatternLayers.CODEC, registryOps).orElse(BannerPatternLayers.EMPTY);
+ this.setPatterns(tag.read("patterns", BannerPatternLayers.CODEC, registryOps).orElse(BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits
@@ -61,7 +_,7 @@
protected void loadAdditional(ValueInput input) {
super.loadAdditional(input);
this.name = parseCustomNameSafe(input, "CustomName");
- this.patterns = input.read("patterns", BannerPatternLayers.CODEC).orElse(BannerPatternLayers.EMPTY);
+ this.setPatterns(input.read("patterns", BannerPatternLayers.CODEC).orElse(BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits
}
@Override
@@ -72,9 +72,18 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
@@ -69,9 +_,18 @@
return ClientboundBlockEntityDataPacket.create(this);
}
@@ -45,7 +37,7 @@ index b61584c533ccb8340c6bd8ad0dbfc3a68600e6cc..8d409e6e768ef6294f41684bc6549b63
}
public BannerPatternLayers getPatterns() {
@@ -94,7 +103,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
@@ -91,7 +_,7 @@
@Override
protected void applyImplicitComponents(DataComponentGetter componentGetter) {
super.applyImplicitComponents(componentGetter);
@@ -54,9 +46,9 @@ index b61584c533ccb8340c6bd8ad0dbfc3a68600e6cc..8d409e6e768ef6294f41684bc6549b63
this.name = componentGetter.get(DataComponents.CUSTOM_NAME);
}
@@ -110,4 +119,13 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
tag.remove("patterns");
tag.remove("CustomName");
@@ -107,4 +_,13 @@
output.discard("patterns");
output.discard("CustomName");
}
+
+ // CraftBukkit start

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c79dae1fe 100644
--- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
@@ -109,6 +109,53 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
@@ -110,6 +_,53 @@
return 3;
}
};
@@ -62,7 +54,7 @@ index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c
@Nullable
static Holder<MobEffect> filterEffect(@Nullable Holder<MobEffect> effect) {
@@ -166,17 +213,26 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
@@ -167,17 +_,26 @@
blockEntity.lastCheckY++;
}
@@ -91,7 +83,7 @@ index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c
if (blockEntity.lastCheckY >= height) {
blockEntity.lastCheckY = level.getMinY() - 1;
@@ -227,35 +283,100 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
@@ -228,35 +_,100 @@
@Override
public void setRemoved() {
@@ -125,28 +117,32 @@ index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c
- if (beaconLevel >= 4 && Objects.equals(primaryEffect, secondaryEffect)) {
- i = 1;
- }
-
- int i1 = (9 + beaconLevel * 2) * 20;
- AABB aabb = new AABB(pos).inflate(d).expandTowards(0.0, level.getHeight(), 0.0);
- List<Player> entitiesOfClass = level.getEntitiesOfClass(Player.class, aabb);
-
- for (Player player : entitiesOfClass) {
- player.addEffect(new MobEffectInstance(primaryEffect, i1, i, true, true));
- }
-
- if (beaconLevel >= 4 && !Objects.equals(primaryEffect, secondaryEffect) && secondaryEffect != null) {
- for (Player player : entitiesOfClass) {
- player.addEffect(new MobEffectInstance(secondaryEffect, i1, 0, true, true));
+ double d = computeBeaconRange(beaconLevel); // Paper - diff out applyEffects logic components - see below
+ int i = computeEffectAmplifier(beaconLevel, primaryEffect, secondaryEffect); // Paper - diff out applyEffects logic components - see below
+
+ int i1 = computeEffectDuration(beaconLevel); // Paper - diff out applyEffects logic components - see below
+ List<Player> entitiesOfClass = getHumansInRange(level, pos, beaconLevel, blockEntity); // Paper - diff out applyEffects logic components - see below
- int i1 = (9 + beaconLevel * 2) * 20;
- AABB aabb = new AABB(pos).inflate(d).expandTowards(0.0, level.getHeight(), 0.0);
- List<Player> entitiesOfClass = level.getEntitiesOfClass(Player.class, aabb);
+
+ applyEffectsAndCallEvent(level, pos, entitiesOfClass, new MobEffectInstance(primaryEffect, i1, i, true, true), true); // Paper - BeaconEffectEvent
- for (Player player : entitiesOfClass) {
- player.addEffect(new MobEffectInstance(primaryEffect, i1, i, true, true));
+
+ if (hasSecondaryEffect(beaconLevel, primaryEffect, secondaryEffect)) { // Paper - diff out applyEffects logic components - see below
+ applyEffectsAndCallEvent(level, pos, entitiesOfClass, new MobEffectInstance(secondaryEffect, i1, 0, true, true), false); // Paper - BeaconEffectEvent
}
+ }
+ }
+ }
- if (beaconLevel >= 4 && !Objects.equals(primaryEffect, secondaryEffect) && secondaryEffect != null) {
- for (Player player : entitiesOfClass) {
- player.addEffect(new MobEffectInstance(secondaryEffect, i1, 0, true, true));
+
+ // Paper start - diff out applyEffects logic components
+ // Generally smarter than spigot trying to split the logic up, as that diff is giant.
+ private static int computeEffectDuration(final int beaconLevel) {
@@ -181,6 +177,7 @@ index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c
}
}
}
- }
+ return list;
+ }
+
@@ -200,40 +197,40 @@ index 0c7d0c29ae61c3e9d1c068f27bb84a0d71eb6d17..b77cdbf3e8cf0e9d66c9e5288ebae38c
+ if (!event.callEvent()) continue;
+ player.addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(event.getEffect()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ }
}
+ }
+ // Paper end - BeaconEffectEvent
public static void playSound(Level level, BlockPos pos, SoundEvent sound) {
level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F);
@@ -284,7 +405,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
@@ -285,7 +_,7 @@
@Nullable
private static Holder<MobEffect> loadEffect(CompoundTag tag, String key) {
- return tag.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).filter(VALID_EFFECTS::contains).orElse(null);
+ return tag.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598)
private static Holder<MobEffect> loadEffect(ValueInput input, String key) {
- return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).filter(VALID_EFFECTS::contains).orElse(null);
+ return input.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598)
}
@Override
@@ -292,8 +413,10 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
super.loadAdditional(tag, registries);
this.primaryPower = loadEffect(tag, "primary_effect");
this.secondaryPower = loadEffect(tag, "secondary_effect");
+ this.levels = tag.getIntOr("Levels", 0); // CraftBukkit - SPIGOT-5053, use where available
this.name = parseCustomNameSafe(tag.get("CustomName"), registries);
this.lockKey = LockCode.fromTag(tag, registries);
+ this.effectRange = tag.getDoubleOr(PAPER_RANGE_TAG, -1); // Paper - Custom beacon ranges
@@ -293,8 +_,10 @@
super.loadAdditional(input);
this.primaryPower = loadEffect(input, "primary_effect");
this.secondaryPower = loadEffect(input, "secondary_effect");
+ this.levels = input.getIntOr("Levels", 0); // CraftBukkit - SPIGOT-5053, use where available
this.name = parseCustomNameSafe(input, "CustomName");
this.lockKey = LockCode.fromTag(input);
+ this.effectRange = input.getDoubleOr(PAPER_RANGE_TAG, -1); // Paper - Custom beacon ranges
}
@Override
@@ -304,6 +427,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
tag.putInt("Levels", this.levels);
tag.storeNullable("CustomName", ComponentSerialization.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.name);
this.lockKey.addToTag(tag, registries);
+ tag.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper - Custom beacon ranges
@@ -305,6 +_,7 @@
output.putInt("Levels", this.levels);
output.storeNullable("CustomName", ComponentSerialization.CODEC, this.name);
this.lockKey.addToTag(output);
+ output.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper - Custom beacon ranges
}
public void setCustomName(@Nullable Component name) {
@@ -319,7 +443,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
@@ -320,7 +_,7 @@
@Nullable
@Override
public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a047b70ea 100644
--- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
@@ -79,6 +79,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -82,6 +_,7 @@
private List<BeehiveBlockEntity.BeeData> stored = Lists.newArrayList();
@Nullable
public BlockPos savedFlowerPos;
@@ -16,7 +8,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
public BeehiveBlockEntity(BlockPos pos, BlockState blockState) {
super(BlockEntityType.BEEHIVE, pos, blockState);
@@ -112,7 +113,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -115,7 +_,7 @@
}
public boolean isFull() {
@@ -25,7 +17,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
}
public void emptyAllLivingFromHive(@Nullable Player player, BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) {
@@ -121,7 +122,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -124,7 +_,7 @@
for (Entity entity : list) {
if (entity instanceof Bee bee && player.position().distanceToSqr(entity.position()) <= 16.0) {
if (!this.isSedated()) {
@@ -34,7 +26,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
} else {
bee.setStayOutOfHiveCountdown(400);
}
@@ -131,8 +132,14 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -134,8 +_,14 @@
}
private List<Entity> releaseAllOccupants(BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) {
@@ -50,7 +42,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
if (!list.isEmpty()) {
super.setChanged();
}
@@ -145,6 +152,11 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -148,6 +_,11 @@
return this.stored.size();
}
@@ -62,7 +54,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
public static int getHoneyLevel(BlockState state) {
return state.getValue(BeehiveBlock.HONEY_LEVEL);
}
@@ -155,7 +167,16 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -158,7 +_,16 @@
}
public void addOccupant(Bee bee) {
@@ -80,7 +72,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
bee.stopRiding();
bee.ejectPassengers();
bee.dropLeash();
@@ -180,7 +201,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -183,7 +_,7 @@
this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState()));
}
@@ -89,7 +81,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
super.setChanged();
}
}
@@ -198,7 +219,21 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -201,7 +_,21 @@
BeehiveBlockEntity.BeeReleaseStatus releaseStatus,
@Nullable BlockPos storedFlowerPos
) {
@@ -112,7 +104,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
return false;
} else {
Direction direction = state.getValue(BeehiveBlock.FACING);
@@ -209,6 +244,17 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -212,6 +_,17 @@
} else {
Entity entity = occupant.createEntity(level, pos);
if (entity != null) {
@@ -130,7 +122,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
if (entity instanceof Bee bee) {
if (storedFlowerPos != null && !bee.hasSavedFlowerPos() && level.random.nextFloat() < 0.9F) {
bee.setSavedFlowerPos(storedFlowerPos);
@@ -224,7 +270,13 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -227,7 +_,13 @@
i--;
}
@@ -145,7 +137,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
}
}
}
@@ -233,17 +285,19 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -236,17 +_,19 @@
storedInHives.add(bee);
}
@@ -166,7 +158,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
} else {
return false;
}
@@ -269,6 +323,11 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -272,6 +_,11 @@
flag = true;
iterator.remove();
}
@@ -178,23 +170,23 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
}
}
@@ -292,9 +351,10 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -295,9 +_,10 @@
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
super.loadAdditional(tag, registries);
protected void loadAdditional(ValueInput input) {
super.loadAdditional(input);
- this.stored.clear();
+ this.stored = Lists.newArrayList(); // CraftBukkit - SPIGOT-7790: create new copy (may be modified in physics event triggered by honey change)
tag.read("bees", BeehiveBlockEntity.Occupant.LIST_CODEC).orElse(List.of()).forEach(this::storeBee);
this.savedFlowerPos = tag.read("flower_pos", BlockPos.CODEC).orElse(null);
+ this.maxBees = tag.getIntOr("Bukkit.MaxEntities", MAX_OCCUPANTS); // Paper - persist max bukkit occupants
input.read("bees", BeehiveBlockEntity.Occupant.LIST_CODEC).orElse(List.of()).forEach(this::storeBee);
this.savedFlowerPos = input.read("flower_pos", BlockPos.CODEC).orElse(null);
+ this.maxBees = input.getIntOr("Bukkit.MaxEntities", MAX_OCCUPANTS); // Paper - persist max bukkit occupants
}
@Override
@@ -302,12 +362,13 @@ public class BeehiveBlockEntity extends BlockEntity {
super.saveAdditional(tag, registries);
tag.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees());
tag.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos);
+ tag.putInt("Bukkit.MaxEntities", this.maxBees); // Paper - persist max bukkit occupants
@@ -305,12 +_,13 @@
super.saveAdditional(output);
output.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees());
output.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos);
+ output.putInt("Bukkit.MaxEntities", this.maxBees); // Paper - persist max bukkit occupants
}
@Override
@@ -205,7 +197,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
List<BeehiveBlockEntity.Occupant> list = componentGetter.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees();
list.forEach(this::storeBee);
}
@@ -330,15 +391,18 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -333,15 +_,18 @@
static class BeeData {
private final BeehiveBlockEntity.Occupant occupant;
@@ -225,7 +217,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
}
public BeehiveBlockEntity.Occupant toOccupant() {
@@ -409,6 +473,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -418,6 +_,7 @@
}
private static void setBeeReleaseData(int ticksInHive, Bee bee) {
@@ -233,7 +225,7 @@ index ac4e5cb2eac9e8d7759f836a7e757d3f843d8e54..331eb5416307378162e39e20192ba06a
int age = bee.getAge();
if (age < 0) {
bee.setAge(Math.min(0, age + ticksInHive));
@@ -417,6 +482,7 @@ public class BeehiveBlockEntity extends BlockEntity {
@@ -426,6 +_,7 @@
}
bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive));

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java
index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4fbd8c34a6 100644
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -33,6 +33,10 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -35,6 +_,10 @@
import org.slf4j.Logger;
public abstract class BlockEntity {
@@ -19,7 +11,7 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
private static final Codec<BlockEntityType<?>> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec();
private static final Logger LOGGER = LogUtils.getLogger();
private final BlockEntityType<?> type;
@@ -48,6 +52,7 @@ public abstract class BlockEntity {
@@ -50,6 +_,7 @@
this.worldPosition = pos.immutable();
this.validateBlockState(blockState);
this.blockState = blockState;
@@ -27,7 +19,7 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
}
private void validateBlockState(BlockState state) {
@@ -64,6 +69,7 @@ public abstract class BlockEntity {
@@ -66,6 +_,7 @@
int intOr = tag.getIntOr("x", 0);
int intOr1 = tag.getIntOr("y", 0);
int intOr2 = tag.getIntOr("z", 0);
@@ -35,7 +27,7 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
int sectionPosCoord = SectionPos.blockToSectionCoord(intOr);
int sectionPosCoord1 = SectionPos.blockToSectionCoord(intOr2);
if (sectionPosCoord != chunkPos.x || sectionPosCoord1 != chunkPos.z) {
@@ -71,6 +77,7 @@ public abstract class BlockEntity {
@@ -73,6 +_,7 @@
intOr = chunkPos.getBlockX(SectionPos.sectionRelative(intOr));
intOr2 = chunkPos.getBlockZ(SectionPos.sectionRelative(intOr2));
}
@@ -43,45 +35,44 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
return new BlockPos(intOr, intOr1, intOr2);
}
@@ -89,6 +96,14 @@ public abstract class BlockEntity {
@@ -91,6 +_,12 @@
}
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
protected void loadAdditional(ValueInput input) {
+ // Paper start - read persistent data container
+ this.persistentDataContainer.clear(); // Paper - clear instead of init
+
+ net.minecraft.nbt.Tag persistentDataTag = tag.get("PublicBukkitValues");
+ if (persistentDataTag instanceof CompoundTag) {
+ this.persistentDataContainer.putAll((CompoundTag) persistentDataTag);
+ }
+ input.read("PublicBukkitValues", CompoundTag.CODEC)
+ .ifPresent(this.persistentDataContainer::putAll);
+ // Paper end - read persistent data container
}
public final void loadWithComponents(CompoundTag tag, HolderLookup.Provider registries) {
@@ -120,12 +135,22 @@ public abstract class BlockEntity {
CompoundTag compoundTag = new CompoundTag();
this.saveAdditional(compoundTag, registries);
compoundTag.store(BlockEntity.ComponentHelper.COMPONENTS_CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.components);
public final void loadWithComponents(ValueInput input) {
@@ -140,6 +_,11 @@
public void saveWithoutMetadata(ValueOutput output) {
this.saveAdditional(output);
output.store("components", DataComponentMap.CODEC, this.components);
+ // CraftBukkit start - store container
+ if (!this.persistentDataContainer.isEmpty()) {
+ compoundTag.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
+ output.store("PublicBukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return compoundTag;
}
public final CompoundTag saveCustomOnly(HolderLookup.Provider registries) {
CompoundTag compoundTag = new CompoundTag();
this.saveAdditional(compoundTag, registries);
@@ -155,6 +_,11 @@
public void saveCustomOnly(ValueOutput output) {
this.saveAdditional(output);
+ // Paper start - store PDC here as well
+ if (!this.persistentDataContainer.isEmpty()) {
+ compoundTag.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
+ output.store("PublicBukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound());
+ }
+ // Paper end
return compoundTag;
}
@@ -260,6 +285,12 @@ public abstract class BlockEntity {
private void saveId(ValueOutput output) {
@@ -287,6 +_,12 @@
}
public final void applyComponents(DataComponentMap components, DataComponentPatch patch) {
@@ -94,7 +85,7 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
final Set<DataComponentType<?>> set = new HashSet<>();
set.add(DataComponents.BLOCK_ENTITY_DATA);
set.add(DataComponents.BLOCK_STATE);
@@ -280,6 +311,10 @@ public abstract class BlockEntity {
@@ -307,6 +_,10 @@
});
DataComponentPatch dataComponentPatch = patch.forget(set::contains);
this.components = dataComponentPatch.split().added();
@@ -105,10 +96,11 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
}
protected void collectImplicitComponents(DataComponentMap.Builder components) {
@@ -314,6 +349,28 @@ public abstract class BlockEntity {
.orElse(null);
@@ -339,6 +_,27 @@
public ProblemReporter.PathElement problemPath() {
return new BlockEntity.BlockEntityPathElement(this);
}
+
+ // CraftBukkit start - add method
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return getOwner(true);
@@ -129,8 +121,6 @@ index 5113299200d6bb538977c525754aae95d266bdf7..7783ff94e5183737d01c75c521b70b4f
+ return tag;
+ }
+ // Paper end - Sanitize sent data
+
+
static class ComponentHelper {
public static final MapCodec<DataComponentMap> COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY);
record BlockEntityPathElement(BlockEntity blockEntity) implements ProblemReporter.PathElement {
@Override

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
index aa06834e2f586b80db1cf963005f1415f957c758..780145efef0388c2c316ece0bffd8782256d2ac5 100644
--- a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
@@ -38,6 +38,7 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
@@ -45,6 +_,7 @@
private final NonNullList<ItemStack> items = NonNullList.withSize(4, ItemStack.EMPTY);
public final int[] cookingProgress = new int[4];
public final int[] cookingTime = new int[4];
@@ -16,7 +8,7 @@ index aa06834e2f586b80db1cf963005f1415f957c758..780145efef0388c2c316ece0bffd8782
public CampfireBlockEntity(BlockPos pos, BlockState blockState) {
super(BlockEntityType.CAMPFIRE, pos, blockState);
@@ -56,14 +57,44 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
@@ -63,14 +_,44 @@
ItemStack itemStack = campfire.items.get(i);
if (!itemStack.isEmpty()) {
flag = true;
@@ -63,38 +55,38 @@ index aa06834e2f586b80db1cf963005f1415f957c758..780145efef0388c2c316ece0bffd8782
campfire.items.set(i, ItemStack.EMPTY);
level.sendBlockUpdated(pos, state, state, 3);
level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state));
@@ -135,6 +166,16 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
@@ -142,6 +_,16 @@
.ifPresentOrElse(
ints -> System.arraycopy(ints, 0, this.cookingTime, 0, Math.min(this.cookingTime.length, ints.length)), () -> Arrays.fill(this.cookingTime, 0)
);
+
+ // Paper start - Add more Campfire API
+ tag.getByteArray("Paper.StopCooking").ifPresent(bytes -> {
+ input.read("Paper.StopCooking", com.mojang.serialization.Codec.BYTE_BUFFER).ifPresent(bytes -> {
+ final boolean[] cookingState = new boolean[4];
+ for (int index = 0; index < bytes.length; index++) {
+ cookingState[index] = bytes[index] == 1;
+ for (int index = 0; bytes.hasRemaining() && index < cookingState.length; index++) {
+ cookingState[index] = bytes.get() == 1;
+ }
+ System.arraycopy(cookingState, 0, this.stopCooking, 0, Math.min(this.stopCooking.length, bytes.length));
+ System.arraycopy(cookingState, 0, this.stopCooking, 0, Math.min(this.stopCooking.length, bytes.capacity()));
+ });
+ // Paper end - Add more Campfire API
}
@Override
@@ -143,6 +184,13 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
ContainerHelper.saveAllItems(tag, this.items, true, registries);
tag.putIntArray("CookingTimes", this.cookingProgress);
tag.putIntArray("CookingTotalTimes", this.cookingTime);
@@ -150,6 +_,13 @@
ContainerHelper.saveAllItems(output, this.items, true);
output.putIntArray("CookingTimes", this.cookingProgress);
output.putIntArray("CookingTotalTimes", this.cookingTime);
+ // Paper start - Add more Campfire API
+ byte[] cookingState = new byte[4];
+ for (int index = 0; index < cookingState.length; index++) {
+ cookingState[index] = (byte) (this.stopCooking[index] ? 1 : 0);
+ }
+ tag.putByteArray("Paper.StopCooking", cookingState);
+ output.store("Paper.StopCooking", com.mojang.serialization.Codec.BYTE_BUFFER, java.nio.ByteBuffer.wrap(cookingState));
+ // Paper end - Add more Campfire API
}
@Override
@@ -167,7 +215,15 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
@@ -179,7 +_,15 @@
return false;
}

View File

@@ -0,0 +1,52 @@
--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
@@ -165,8 +_,20 @@
}
private static void applyEffects(Level level, BlockPos pos, List<BlockPos> positions) {
+ // CraftBukkit start
+ ConduitBlockEntity.applyEffects(level, pos, ConduitBlockEntity.getRange(positions));
+ }
+
+ public static int getRange(List<BlockPos> positions) {
+ // CraftBukkit end
int size = positions.size();
int i = size / 7 * 16;
+ // CraftBukkit start
+ return i;
+ }
+
+ private static void applyEffects(Level level, BlockPos pos, int i) { // i = effect range in blocks
+ // CraftBukkit end
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
@@ -175,20 +_,25 @@
if (!entitiesOfClass.isEmpty()) {
for (Player player : entitiesOfClass) {
if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) {
- player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+ player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
}
}
}
}
private static void updateAndAttackTarget(ServerLevel level, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity, boolean canDestroy) {
+ // CraftBukkit start - add "damageTarget" boolean
+ updateAndAttackTarget(level, pos, state, blockEntity, canDestroy, true);
+ }
+ private static void updateAndAttackTarget(ServerLevel level, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity, boolean canDestroy, boolean damageTarget) {
+ // CraftBukkit end - add "damageTarget" boolean
EntityReference<LivingEntity> entityReference = updateDestroyTarget(blockEntity.destroyTarget, level, pos, canDestroy);
LivingEntity livingEntity = EntityReference.get(entityReference, level, LivingEntity.class);
- if (livingEntity != null) {
+ if (damageTarget && livingEntity != null) { // CraftBukkit
+ if (livingEntity.hurtServer(level, level.damageSources().magic(), 4.0F)) // CraftBukkit - move up
level.playSound(
null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F
);
- livingEntity.hurtServer(level, level.damageSources().magic(), 4.0F);
}
if (!Objects.equals(entityReference, blockEntity.destroyTarget)) {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
index 5a160a0eaddab38d281c2a4f732619b43b6afa3e..25bf19ccbd920538dba82fa20de214f374b8c3f2 100644
--- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
@@ -24,6 +24,48 @@ import net.minecraft.world.level.storage.loot.LootTable;
@@ -23,6 +_,48 @@
import net.minecraft.world.ticks.ContainerSingleItem;
public class DecoratedPotBlockEntity extends BlockEntity implements RandomizableContainer, ContainerSingleItem.BlockContainerSingleItem {
@@ -57,18 +49,18 @@ index 5a160a0eaddab38d281c2a4f732619b43b6afa3e..25bf19ccbd920538dba82fa20de214f3
public static final String TAG_SHERDS = "sherds";
public static final String TAG_ITEM = "item";
public static final int EVENT_POT_WOBBLES = 1;
@@ -48,8 +90,8 @@ public class DecoratedPotBlockEntity extends BlockEntity implements Randomizable
tag.store("sherds", PotDecorations.CODEC, this.decorations);
@@ -47,8 +_,8 @@
output.store("sherds", PotDecorations.CODEC, this.decorations);
}
- if (!this.trySaveLootTable(tag) && !this.item.isEmpty()) {
- tag.store("item", ItemStack.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.item);
+ if (!this.trySaveLootTable(tag) && !this.item.isEmpty()) { // Paper - diff on change - hide unnecessary update data
+ tag.store("item", ItemStack.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.item); // Paper - diff on change - hide unnecessary update data
- if (!this.trySaveLootTable(output) && !this.item.isEmpty()) {
- output.store("item", ItemStack.CODEC, this.item);
+ if (!this.trySaveLootTable(output) && !this.item.isEmpty()) { // Paper - diff on change - hide unnecessary update data
+ output.store("item", ItemStack.CODEC, this.item); // Paper - diff on change - hide unnecessary update data
}
}
@@ -72,7 +114,14 @@ public class DecoratedPotBlockEntity extends BlockEntity implements Randomizable
@@ -70,7 +_,14 @@
@Override
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {

View File

@@ -0,0 +1,42 @@
--- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java
@@ -21,6 +_,7 @@
private final VibrationSystem.Listener vibrationListener;
private final VibrationSystem.User vibrationUser;
public int lastVibrationFrequency = 0;
+ @Nullable public Integer rangeOverride = null; // Paper - Configurable sculk sensor listener range
protected SculkSensorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) {
super(type, pos, blockState);
@@ -42,14 +_,22 @@
super.loadAdditional(input);
this.lastVibrationFrequency = input.getIntOr("last_vibration_frequency", 0);
this.vibrationData = input.read("listener", VibrationSystem.Data.CODEC).orElseGet(VibrationSystem.Data::new);
+ this.rangeOverride = input.getInt(PAPER_LISTENER_RANGE_NBT_KEY).orElse(null); // Paper start - Configurable sculk sensor listener range
}
+ protected static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper - Configurable sculk sensor listener range
@Override
protected void saveAdditional(ValueOutput output) {
super.saveAdditional(output);
output.putInt("last_vibration_frequency", this.lastVibrationFrequency);
output.store("listener", VibrationSystem.Data.CODEC, this.vibrationData);
- }
+ this.saveRangeOverride(output); // Paper - Configurable sculk sensor listener range
+ }
+ // Paper start - Configurable sculk sensor listener range
+ protected void saveRangeOverride(ValueOutput output) {
+ if (this.rangeOverride != null && this.rangeOverride != VibrationUser.LISTENER_RANGE) output.putInt(PAPER_LISTENER_RANGE_NBT_KEY, this.rangeOverride); // only save if it's different from the default
+ }
+ // Paper end - Configurable sculk sensor listener range
@Override
public VibrationSystem.Data getVibrationData() {
@@ -86,6 +_,7 @@
@Override
public int getListenerRadius() {
+ if (SculkSensorBlockEntity.this.rangeOverride != null) return SculkSensorBlockEntity.this.rangeOverride; // Paper - Configurable sculk sensor listener range
return 8;
}

View File

@@ -0,0 +1,19 @@
--- a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java
@@ -154,6 +_,7 @@
@Override
protected void loadAdditional(ValueInput input) {
+ super.loadAdditional(input); // Paper - load the PDC
input.read("data", TestInstanceBlockEntity.Data.CODEC).ifPresent(this::set);
}
@@ -317,7 +_,7 @@
}
private void removeEntities() {
- this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach(Entity::discard);
+ this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach((entity) -> entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper
}
private void forceLoadChunks() {