Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-data/paper.at
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ public net.minecraft.world.level.block.entity.BarrelBlockEntity playSound(Lnet/m
public net.minecraft.world.level.block.entity.BarrelBlockEntity updateBlockState(Lnet/minecraft/world/level/block/state/BlockState;Z)V
public net.minecraft.world.level.block.entity.BaseContainerBlockEntity lockKey
public net.minecraft.world.level.block.entity.BaseContainerBlockEntity name
public net.minecraft.world.level.block.entity.BeaconBlockEntity MAX_LEVELS
public net.minecraft.world.level.block.entity.BeaconBlockEntity levels
public net.minecraft.world.level.block.entity.BeaconBlockEntity lockKey
public net.minecraft.world.level.block.entity.BeaconBlockEntity name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
return stillValid(this.access, player, Blocks.BEACON);
}

@@ -143,13 +_,30 @@
@@ -143,13 +_,53 @@
public @Nullable Holder<MobEffect> getSecondaryEffect() {
return decodeEffect(this.beaconData.get(2));
}
Expand All @@ -75,11 +75,34 @@
+ // Paper end - Add PlayerChangeBeaconEffectEvent

- public void updateEffects(final Optional<Holder<MobEffect>> primary, final Optional<Holder<MobEffect>> secondary) {
+ public void updateEffects(final Optional<Holder<MobEffect>> primary, Optional<Holder<MobEffect>> secondary) { // Paper - fix MC-174630 - make non-final
+ public void updateEffects(Optional<Holder<MobEffect>> primary, Optional<Holder<MobEffect>> secondary) { // Paper - fix MC-174630 - make non-final
+ // Paper start - fix MC-174630 - validate secondary power
+ if (secondary.isPresent() && secondary.get() != net.minecraft.world.effect.MobEffects.REGENERATION && (primary.isPresent() && secondary.get() != primary.get())) {
+ secondary = Optional.empty();
+ }
+ if (!(this.access.getWorld().getBlockEntity(this.access.getPosition()) instanceof net.minecraft.world.level.block.entity.BeaconBlockEntity beaconEntity)) {
+ return;
+ }
+ // Only max level beacon is allowed to have a secondary effect
+ if (beaconEntity.levels != net.minecraft.world.level.block.entity.BeaconBlockEntity.MAX_LEVELS) {
+ secondary = Optional.empty();
+ }
+ if (primary.isPresent()) {
+ boolean primaryAllowed = false;
+ // Regeneration can never be the primary effect, so we only check up until the second to last level
+ for (int i = 0; i < Math.min(beaconEntity.levels, net.minecraft.world.level.block.entity.BeaconBlockEntity.MAX_LEVELS - 1); i++) {
+ java.util.List<Holder<MobEffect>> allowedEffects = net.minecraft.world.level.block.entity.BeaconBlockEntity.BEACON_EFFECTS.get(i);
+ if (allowedEffects.contains(primary.get())) {
+ primaryAllowed = true;
+ break;
+ }
+ }
+ if (!primaryAllowed) {
+ // Secondary must always be cleared: a beacon can't have just a secondary effect
+ primary = Optional.empty();
+ secondary = Optional.empty();
+ }
+ }
+ // Paper end
if (this.paymentSlot.hasItem()) {
- this.beaconData.set(1, encodeEffect(primary.orElse(null)));
Expand Down
Loading