mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-26 03:10:29 +00:00
67 lines
3.3 KiB
Diff
67 lines
3.3 KiB
Diff
--- a/net/minecraft/world/entity/InsideBlockEffectApplier.java
|
|
+++ b/net/minecraft/world/entity/InsideBlockEffectApplier.java
|
|
@@ -32,7 +_,7 @@
|
|
public static class StepBasedCollector implements InsideBlockEffectApplier {
|
|
private static final InsideBlockEffectType[] APPLY_ORDER = InsideBlockEffectType.values();
|
|
private static final int NO_STEP = -1;
|
|
- private final Set<InsideBlockEffectType> effectsInStep = EnumSet.noneOf(InsideBlockEffectType.class);
|
|
+ private final Map<InsideBlockEffectType, Consumer<Entity>> effectsInStep = new java.util.EnumMap<>(InsideBlockEffectType.class); // Paper - track position inside effect was triggered on
|
|
private final Map<InsideBlockEffectType, List<Consumer<Entity>>> beforeEffectsInStep = Util.makeEnumMap(
|
|
InsideBlockEffectType.class, insideBlockEffectType -> new ArrayList<>()
|
|
);
|
|
@@ -42,7 +_,8 @@
|
|
private final List<Consumer<Entity>> finalEffects = new ArrayList<>();
|
|
private int lastStep = -1;
|
|
|
|
- public void advanceStep(int step) {
|
|
+ public void advanceStep(int step, net.minecraft.core.BlockPos pos) { // Paper - track position inside effect was triggered on
|
|
+ this.currentBlockPos = pos; // Paper - track position inside effect was triggered on
|
|
if (this.lastStep != step) {
|
|
this.lastStep = step;
|
|
this.flushStep();
|
|
@@ -69,8 +_,8 @@
|
|
List<Consumer<Entity>> list = this.beforeEffectsInStep.get(insideBlockEffectType);
|
|
this.finalEffects.addAll(list);
|
|
list.clear();
|
|
- if (this.effectsInStep.remove(insideBlockEffectType)) {
|
|
- this.finalEffects.add(insideBlockEffectType.effect());
|
|
+ if (this.effectsInStep.remove(insideBlockEffectType) instanceof final Consumer<Entity> recordedEffect) { // Paper - track position inside effect was triggered on - better than null check to avoid diff.
|
|
+ this.finalEffects.add(recordedEffect); // Paper - track position inside effect was triggered on
|
|
}
|
|
|
|
List<Consumer<Entity>> list1 = this.afterEffectsInStep.get(insideBlockEffectType);
|
|
@@ -81,7 +_,7 @@
|
|
|
|
@Override
|
|
public void apply(InsideBlockEffectType type) {
|
|
- this.effectsInStep.add(type);
|
|
+ this.effectsInStep.put(type, recorded(type)); // Paper - track position inside effect was triggered on
|
|
}
|
|
|
|
@Override
|
|
@@ -93,5 +_,24 @@
|
|
public void runAfter(InsideBlockEffectType type, Consumer<Entity> effect) {
|
|
this.afterEffectsInStep.get(type).add(effect);
|
|
}
|
|
+
|
|
+ // Paper start - track position inside effect was triggered on
|
|
+ private net.minecraft.core.BlockPos currentBlockPos = null;
|
|
+
|
|
+ private Consumer<Entity> recorded(final InsideBlockEffectType type) {
|
|
+ return new RecordedEffect(this.currentBlockPos.immutable(), type.effect());
|
|
+ }
|
|
+
|
|
+ record RecordedEffect(
|
|
+ net.minecraft.core.BlockPos blockPos,
|
|
+ InsideBlockEffectType.Applier applier
|
|
+ ) implements Consumer<Entity> {
|
|
+
|
|
+ @Override
|
|
+ public void accept(final Entity entity) {
|
|
+ this.applier.affect(entity, blockPos);
|
|
+ }
|
|
+ }
|
|
+ // Paper end - track position inside effect was triggered on
|
|
}
|
|
}
|