Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 19:40:07 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
132 Zeilen
6.5 KiB
Diff
132 Zeilen
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Wed, 24 Jun 2020 12:39:08 -0600
|
|
Subject: [PATCH] Beacon API - custom effect ranges
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
index 349b89dd4d34b92d1077ddadb30c36642fd85622..812d21393ed2ed0623b7445585f1b0b3dcefb55d 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
@@ -76,6 +76,26 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, BeaconBlockEntity.getLevel(this.levels), BeaconBlockEntity.getAmplification(this.levels, this.primaryPower, this.secondaryPower), true, true)) : null;
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start - add field/methods for custom range
|
|
+ private final String PAPER_RANGE_TAG = "Paper.Range";
|
|
+ private double effectRange = -1;
|
|
+
|
|
+ public double getEffectRange() {
|
|
+ if (this.effectRange < 0) {
|
|
+ return this.levels * 10 + 10;
|
|
+ } else {
|
|
+ return effectRange;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void setEffectRange(double range) {
|
|
+ this.effectRange = range;
|
|
+ }
|
|
+
|
|
+ public void resetEffectRange() {
|
|
+ this.effectRange = -1;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public BeaconBlockEntity(BlockPos pos, BlockState state) {
|
|
super(BlockEntityType.BEACON, pos, state);
|
|
@@ -186,7 +206,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
}
|
|
|
|
if (blockEntity.levels > 0 && !blockEntity.beamSections.isEmpty()) {
|
|
- BeaconBlockEntity.applyEffects(world, pos, blockEntity.levels, blockEntity.primaryPower, blockEntity.secondaryPower);
|
|
+ BeaconBlockEntity.applyEffects(world, pos, blockEntity.levels, blockEntity.primaryPower, blockEntity.secondaryPower, blockEntity); // Paper
|
|
BeaconBlockEntity.playSound(world, pos, SoundEvents.BEACON_AMBIENT);
|
|
}
|
|
}
|
|
@@ -272,8 +292,13 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
}
|
|
|
|
public static List getHumansInRange(Level world, BlockPos blockposition, int i) {
|
|
+ // Paper start
|
|
+ return BeaconBlockEntity.getHumansInRange(world, blockposition, i, null);
|
|
+ }
|
|
+ public static List getHumansInRange(Level world, BlockPos blockposition, int i, @Nullable BeaconBlockEntity blockEntity) {
|
|
+ // Paper end
|
|
{
|
|
- double d0 = (double) (i * 10 + 10);
|
|
+ double d0 = blockEntity != null ? blockEntity.getEffectRange() : (i * 10 + 10);// Paper - custom beacon ranges
|
|
|
|
AABB axisalignedbb = (new AABB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
|
|
List<Player> list = world.getEntitiesOfClass(Player.class, axisalignedbb);
|
|
@@ -314,12 +339,17 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
}
|
|
|
|
private static void applyEffects(Level world, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect) {
|
|
+ // Paper start
|
|
+ BeaconBlockEntity.applyEffects(world, pos, beaconLevel, primaryEffect, secondaryEffect, null);
|
|
+ }
|
|
+ private static void applyEffects(Level world, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect, @Nullable BeaconBlockEntity blockEntity) {
|
|
+ // Paper end
|
|
if (!world.isClientSide && primaryEffect != null) {
|
|
double d0 = (double) (beaconLevel * 10 + 10);
|
|
byte b0 = BeaconBlockEntity.getAmplification(beaconLevel, primaryEffect, secondaryEffect);
|
|
|
|
int j = BeaconBlockEntity.getLevel(beaconLevel);
|
|
- List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel);
|
|
+ List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel, blockEntity); // Paper
|
|
|
|
BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent
|
|
|
|
@@ -369,6 +399,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
}
|
|
|
|
this.lockKey = LockCode.fromTag(nbt);
|
|
+ this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -382,6 +413,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
|
}
|
|
|
|
this.lockKey.addToTag(nbt);
|
|
+ nbt.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper
|
|
}
|
|
|
|
public void setCustomName(@Nullable Component customName) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
index c186a44b927188ed222f8b2f8f76aaef35d9c654..c47e613cae3d9252a8364ccc4d717e410bb0fc0c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
|
@@ -29,7 +29,7 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
|
if (tileEntity instanceof BeaconBlockEntity) {
|
|
BeaconBlockEntity beacon = (BeaconBlockEntity) tileEntity;
|
|
|
|
- Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels);
|
|
+ Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels, beacon); // Paper
|
|
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
|
|
|
|
for (Player human : nms) {
|
|
@@ -106,4 +106,21 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
|
public void setLock(String key) {
|
|
this.getSnapshot().lockKey = (key == null) ? LockCode.NO_LOCK : new LockCode(key);
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public double getEffectRange() {
|
|
+ return this.getSnapshot().getEffectRange();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setEffectRange(double range) {
|
|
+ this.getSnapshot().setEffectRange(range);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void resetEffectRange() {
|
|
+ this.getSnapshot().resetEffectRange();
|
|
+ }
|
|
+ // Paper end
|
|
}
|