Skip to content

Commit

Permalink
Fixed ender dragon fights not working in 1.20 (#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jun 26, 2023
1 parent 2167933 commit 3e5ad13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -32,9 +32,8 @@ public class NMSDragonFightImpl implements NMSDragonFight {
EntityType.class, EntityType.EntityFactory.class, Modifier.PRIVATE | Modifier.FINAL, 1)
.removeFinal();

private static final ReflectField<EndDragonFight> WORLD_DRAGON_BATTLE = new ReflectField<EndDragonFight>(
ServerLevel.class, EndDragonFight.class, Modifier.PRIVATE | Modifier.FINAL, 1)
.removeFinal();
private static final ReflectField<EndDragonFight> WORLD_DRAGON_BATTLE = new ReflectField<>(
ServerLevel.class, EndDragonFight.class, Modifier.PRIVATE, 1);

private static final ReflectField<LoadingCache<Long, List<SpikeFeature.EndSpike>>> SPIKE_CACHE = new ReflectField<LoadingCache<Long, List<SpikeFeature.EndSpike>>>(
SpikeFeature.class, LoadingCache.class, Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL, 1)
Expand Down
Expand Up @@ -40,9 +40,12 @@ public class IslandEndDragonFight extends EndDragonFight {
EnderDragon.class, EndDragonFight.class, Modifier.PRIVATE | Modifier.FINAL, 1)
.removeFinal();
private static final ReflectField<Boolean> SCAN_FOR_LEGACY_PORTALS = new ReflectField<>(
EndDragonFight.class, boolean.class, Modifier.PRIVATE, 3);
EndDragonFight.class, boolean.class, Modifier.PRIVATE, 4);
private static final ReflectField<Boolean> WAS_DRAGON_KILLED = new ReflectField<>(
EndDragonFight.class, boolean.class, Modifier.PRIVATE, 1);

private static final ReflectField<Integer> TICKS_SINCE_LAST_PLAYER_SCAN = new ReflectField<>(
EndDragonFight.class, int.class, Modifier.PRIVATE, 4);
private static final ReflectField<Vec3> LANDING_TARGET_POSITION = new ReflectField<>(
DragonLandingPhase.class, Vec3.class, Modifier.PRIVATE, 1);

Expand Down Expand Up @@ -80,6 +83,8 @@ public IslandEndDragonFight(Island island, ServerLevel serverLevel, BlockPos isl
SCAN_FOR_LEGACY_PORTALS.set(this, false);
WAS_DRAGON_KILLED.set(this, false);
DRAGON_BATTLE.set(this.entityEnderDragon, this);

TICKS_SINCE_LAST_PLAYER_SCAN.set(this, Integer.MIN_VALUE);
}

@Override
Expand All @@ -96,6 +101,7 @@ public void tick() {
if (++currentTick >= 20) {
updateBattlePlayers();
currentTick = 0;
TICKS_SINCE_LAST_PLAYER_SCAN.set(this, Integer.MIN_VALUE);
}
}

Expand Down

0 comments on commit 3e5ad13

Please sign in to comment.