Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config support for generating tower #38

Open
wants to merge 2 commits into
base: 1.20
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public void betterendisland_tickFight(CallbackInfo ci) {
BetterEndIslandCommon.LOGGER.info("Found that the dragon has not yet been killed in this world.");
this.previouslyKilled = false;
if (this.findExitPortal() == null) {
this.betterendisland$spawnPortal(false, false);
this.betterendisland$spawnPortal(false, false, true);
}
}

Expand Down Expand Up @@ -432,8 +432,8 @@ public void betterendisland_tryRespawn(CallbackInfo ci) {
BlockPattern.BlockPatternMatch portalPatternMatch = this.findExitPortal();
if (portalPatternMatch == null) {
BetterEndIslandCommon.LOGGER.info("Couldn't find a portal, so we made one.");
this.betterendisland$spawnPortal(false, false);
this.betterendisland$spawnPortal(true, true); // Place open, active bottom after spawning tower
this.betterendisland$spawnPortal(false, false, true);
this.betterendisland$spawnPortal(true, true, true); // Place open, active bottom after spawning tower
} else {
BetterEndIslandCommon.LOGGER.info("Found the exit portal & saved its location for next time.");
}
Expand Down Expand Up @@ -470,8 +470,8 @@ public void betterendisland_tryRespawn(CallbackInfo ci) {
BlockPattern.BlockPatternMatch portalPatternMatch = this.findExitPortal();
if (portalPatternMatch == null) {
BetterEndIslandCommon.LOGGER.info("Couldn't find a portal, so we made one.");
this.betterendisland$spawnPortal(false, false);
this.betterendisland$spawnPortal(true, true); // Place open, active bottom after spawning tower
this.betterendisland$spawnPortal(false, false, true);
this.betterendisland$spawnPortal(true, true, true); // Place open, active bottom after spawning tower
} else {
BetterEndIslandCommon.LOGGER.info("Found the exit portal & saved its location for next time.");
}
Expand Down Expand Up @@ -530,7 +530,7 @@ private void betterendisland_respawnDragon(List<EndCrystal> crystals, CallbackIn
}

@Unique
private void betterendisland$spawnPortal(boolean isActive, boolean isBottomOnly) {
private void betterendisland$spawnPortal(boolean isActive, boolean isBottomOnly, boolean regenerateTemple) {
// Find the portal location if it hasn't been found yet
if (this.portalLocation == null || this.portalLocation.getY() < 5) {
if (this.portalLocation == null) {
Expand All @@ -550,9 +550,32 @@ private void betterendisland_respawnDragon(List<EndCrystal> crystals, CallbackIn

BetterEndIslandCommon.LOGGER.info("Set the exit portal location to: {}", this.portalLocation);

BetterEndPodiumFeature endPodiumFeature = new BetterEndPodiumFeature(this.betterendisland$firstExitPortalSpawn, isBottomOnly, isActive);
BlockPos spawnPos = this.portalLocation.below(5);
endPodiumFeature.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), spawnPos);
// If the dragon has never been killed, place the structure regardless of config settings.
if(!this.previouslyKilled || regenerateTemple){
BetterEndIslandCommon.LOGGER.info("Placing End Tower");
BetterEndPodiumFeature endPodiumFeature = new BetterEndPodiumFeature(this.betterendisland$firstExitPortalSpawn, isBottomOnly, isActive);
BlockPos spawnPos = this.portalLocation.below(5);
endPodiumFeature.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), spawnPos);
} else {
if(isActive && !this.hasActiveExitPortal()) {
BetterEndIslandCommon.LOGGER.info("Activating exit portal");
BlockPos portalLocation = this.portalLocation.below(3);

// End portal block x/y coordinate pattern relative to a bedrock center at 0,0
int[][] portalPattern = {
{-1, 2}, {0, 2}, {1, 2},
{-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1},
{-2, 0}, {-1, 0}, {1, 0}, {2, 0},
{-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1},
{-1, -2}, {0, -2}, {1, -2}
};

for (int[] offset : portalPattern) {
BlockPos pos = portalLocation.offset(offset[0], 0, offset[1]);
this.level.setBlockAndUpdate(pos, Blocks.END_PORTAL.defaultBlockState());
}
}
}
this.betterendisland$firstExitPortalSpawn = false;
}

Expand Down Expand Up @@ -583,10 +606,10 @@ public void betterendisland_setDragonKilled(EnderDragon dragon, CallbackInfo ci)
if (dragon.getUUID().equals(this.dragonUUID)) {
this.dragonEvent.setProgress(0.0F);
this.dragonEvent.setVisible(false);
this.betterendisland$spawnPortal(true, true);
this.betterendisland$spawnPortal(true, true, BetterEndIslandCommon.CONFIG.regenerateTowerOnDragonDeath);
level.explode(null, this.portalLocation.getX(), this.portalLocation.getY(), this.portalLocation.getZ(), 6.0F, Level.ExplosionInteraction.NONE);
this.spawnNewGateway();
if (!this.previouslyKilled || BetterEndIslandCommon.moreDragonEggs || BetterEndIslandCommon.CONFIG.resummonedDragonDropsEgg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come the check for BetterEndIslandCommon.CONFIG.resummonedDragonDropsEgg was removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that was an inadverent change. Will add back.

if (!this.previouslyKilled || BetterEndIslandCommon.moreDragonEggs) {
this.level.setBlockAndUpdate(this.portalLocation.above(), Blocks.DRAGON_EGG.defaultBlockState());
}

Expand Down Expand Up @@ -626,7 +649,7 @@ public void betterendisland_setDragonKilled(EnderDragon dragon, CallbackInfo ci)
}

// Place broken tower w/ explosion effects
this.betterendisland$spawnPortal(false, false);
this.betterendisland$spawnPortal(false, false, BetterEndIslandCommon.CONFIG.regenerateTowerOnDragonDeath);
level.explode(null, this.portalLocation.getX(), this.portalLocation.getY() + 20, this.portalLocation.getZ(), 6.0F, Level.ExplosionInteraction.NONE);
level.players().forEach(player -> {
level.sendParticles(player, ParticleTypes.EXPLOSION_EMITTER, true, this.portalLocation.getX(), this.portalLocation.getY() + 20, this.portalLocation.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
Expand All @@ -636,7 +659,7 @@ public void betterendisland_setDragonKilled(EnderDragon dragon, CallbackInfo ci)
});
// Place open, inactive bottom if we're not transitioning from an initial tower
if (this.betterendisland$hasDragonEverSpawned) {
this.betterendisland$spawnPortal(false, true);
this.betterendisland$spawnPortal(false, true, BetterEndIslandCommon.CONFIG.regenerateTowerOnDragonDeath);
level.explode(null, this.portalLocation.getX(), this.portalLocation.getY(), this.portalLocation.getZ(), 6.0F, Level.ExplosionInteraction.NONE);
}

Expand Down Expand Up @@ -728,4 +751,4 @@ public void betterendisland_setDragonKilled(EnderDragon dragon, CallbackInfo ci)
public void betterendisland$setNumTimesDragonKilled(int i) {
this.betterendisland$numberTimesDragonKilled = i;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public class ConfigModule {
public boolean resummonedDragonDropsEgg = false;
public boolean useVanillaSpawnPlatform = false;
public boolean regenerateTowerOnDragonDeath = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ public class ConfigGeneralFabric {

@ConfigEntry.Gui.Tooltip
public boolean useVanillaSpawnPlatform = false;

@ConfigEntry.Gui.Tooltip
public boolean regenerateTowerOnDragonDeath = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ private static InteractionResult bakeConfig(ConfigHolder<BEIConfigFabric> config
private static void bakeConfig(BEIConfigFabric configFabric) {
BetterEndIslandCommon.CONFIG.resummonedDragonDropsEgg = configFabric.general.resummonedDragonDropsEgg;
BetterEndIslandCommon.CONFIG.useVanillaSpawnPlatform = configFabric.general.useVanillaSpawnPlatform;
BetterEndIslandCommon.CONFIG.regenerateTowerOnDragonDeath = configFabric.general.regenerateTowerOnDragonDeath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class BEIConfigForge {

public static final ForgeConfigSpec.ConfigValue<Boolean> resummonedDragonDropsEgg;
public static final ForgeConfigSpec.ConfigValue<Boolean> useVanillaSpawnPlatform;
public static final ForgeConfigSpec.ConfigValue<Boolean> regenerateTowerOnDragonDeath;

static {
BUILDER.push("YUNG's Better End Island");
Expand All @@ -24,6 +25,12 @@ public class BEIConfigForge {
" Default: false")
.define("Spawn Vanilla Obsidian Platform", false);

regenerateTowerOnDragonDeath = BUILDER
.comment(
" Whether the tower building surrounding the end podium should be regenerated on subsequent dragon kills. \n" +
" Default: false")
.define("Regenerate End Podium Tower", true);

BUILDER.pop();
SPEC = BUILDER.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ private static void onConfigChange(ModConfigEvent event) {
private static void bakeConfig() {
BetterEndIslandCommon.CONFIG.resummonedDragonDropsEgg = BEIConfigForge.resummonedDragonDropsEgg.get();
BetterEndIslandCommon.CONFIG.useVanillaSpawnPlatform = BEIConfigForge.useVanillaSpawnPlatform.get();
BetterEndIslandCommon.CONFIG.regenerateTowerOnDragonDeath = BEIConfigForge.regenerateTowerOnDragonDeath.get();
}
}