More dragon respawn fixes

This commit is contained in:
paulevsGitch 2021-05-03 23:27:22 +03:00
parent 28cd23f378
commit 20176730f9
7 changed files with 90 additions and 15 deletions

View file

@ -52,25 +52,25 @@ public class EndDragonFightMixin {
@Inject(method = "tryRespawn", at = @At("HEAD"), cancellable = true)
private void be_tryRespawnDragon(CallbackInfo info) {
if (GeneratorOptions.replacePortal() && GeneratorOptions.hasDragonFights() && this.dragonKilled && this.respawnStage == null) {
BlockPos blockPos = this.portalLocation;
BlockPos blockPos = portalLocation;
if (blockPos == null) {
LOGGER.debug("Tried to respawn, but need to find the portal first.");
BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal();
if (blockPatternMatch == null) {
LOGGER.debug("Couldn't find a portal, so we made one.");
this.spawnExitPortal(true);
spawnExitPortal(true);
}
else {
LOGGER.debug("Found the exit portal & temporarily using it.");
}
blockPos = this.portalLocation;
blockPos = portalLocation;
}
List<EndCrystal> crystals = Lists.newArrayList();
BlockPos center = blockPos.above(2);
BlockPos center = GeneratorOptions.getPortalPos().above(5);
for (Direction dir : BlocksHelper.HORIZONTAL) {
List<EndCrystal> crystalList = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(dir, 3)));
List<EndCrystal> crystalList = level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(dir, 4)));
if (crystalList.isEmpty()) {
info.cancel();
return;
@ -80,7 +80,7 @@ public class EndDragonFightMixin {
}
LOGGER.debug("Found all crystals, respawning dragon.");
this.respawnDragon(crystals);
respawnDragon(crystals);
info.cancel();
}
}

View file

@ -0,0 +1,43 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.levelgen.feature.SpikeFeature.EndSpike;
import ru.betterend.util.WorldDataUtil;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndSpike.class)
public class EndSpikeMixin {
@Final
@Shadow
private int height;
@Inject(method = "getHeight", at = @At("HEAD"), cancellable = true)
private void be_getSpikeHeight(CallbackInfoReturnable<Integer> info) {
if (!GeneratorOptions.isDirectSpikeHeight()) {
int x = getCenterX();
int z = getCenterZ();
String pillarID = String.format("%d_%d", x, z);
CompoundTag pillar = WorldDataUtil.getCompoundTag("pillars");
int minY = pillar.contains(pillarID) ? pillar.getInt(pillarID) : 65;
int maxY = minY + height - 54;
info.setReturnValue(maxY);
}
}
@Shadow
public int getCenterX() {
return 0;
}
@Shadow
public int getCenterZ() {
return 0;
}
}

View file

@ -63,6 +63,7 @@ public class SpikeFeatureMixin {
minY = world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z);
}
GeneratorOptions.setDirectSpikeHeight();
int maxY = minY + spike.getHeight() - 64;
if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) {