From 8c1acec7c0837cc93e28a031e381f62f488f3cb1 Mon Sep 17 00:00:00 2001 From: SuperSoupr <26164930+SuperSoupr@users.noreply.github.com> Date: Thu, 16 Jul 2026 01:12:49 +0300 Subject: [PATCH 1/2] end of time improvements --- .../common/blocks/BlockPortalEndOfTime.java | 119 +++++++++++------- ...ortalData.java => PlatformAnchorData.java} | 22 ++-- .../endoftime/WorldProviderEndOfTime.java | 33 ++++- 3 files changed, 112 insertions(+), 62 deletions(-) rename src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/{DimensionPortalData.java => PlatformAnchorData.java} (65%) diff --git a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java index 84c90838a..46a86d54d 100644 --- a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java +++ b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java @@ -26,8 +26,8 @@ import com.fouristhenumber.utilitiesinexcess.ModBlocks; import com.fouristhenumber.utilitiesinexcess.common.dimensions.UIETeleporter; -import com.fouristhenumber.utilitiesinexcess.common.dimensions.endoftime.DimensionPortalData; import com.fouristhenumber.utilitiesinexcess.common.dimensions.endoftime.EndOfTimeSourceProperty; +import com.fouristhenumber.utilitiesinexcess.common.dimensions.endoftime.PlatformAnchorData; import com.fouristhenumber.utilitiesinexcess.common.dimensions.endoftime.WorldProviderEndOfTime; import com.fouristhenumber.utilitiesinexcess.config.dimensions.EndOfTimeConfig; import com.gtnewhorizon.gtnhlib.blockpos.BlockPos; @@ -75,7 +75,7 @@ public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { @Override public int onBlockPlaced(World world, int x, int y, int z, int side, float subX, float subY, float subZ, int meta) { if (!world.isRemote && world.provider instanceof WorldProviderEndOfTime) { - DimensionPortalData.get(world) + PlatformAnchorData.get(world) .setTarget(x, y, z); } return meta; @@ -108,21 +108,28 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p } else { WorldServer dest = MinecraftServer.getServer() .worldServerForDimension(EndOfTimeConfig.INSTANCE.endOfTimeDimensionId); - if (dest.getBlock(0, 64, 0) != Blocks.bedrock) { - generateSpawnArea(dest, 0, 65, 0); + // Extra Utilities has it's End of Time equivalent's platform generate at world spawn, so we replicate that + // behavior for compatibility with older saves. + // However, this lead to a bug causing the platform to generate multiple times if world spawn was ever + // changed, so anchor it the first time we're loaded. + if (PlatformAnchorData.get(dest) + .isZero()) { + ChunkCoordinates origin = dest.getSpawnPoint(); + if (dest.getBlock(origin.posX, 63, origin.posZ) != Blocks.bedrock) { + generateSpawnArea(dest, origin.posX, 64, origin.posZ); + } + PlatformAnchorData.get(dest) + .setTarget(origin.posX, 64, origin.posZ); } - ChunkCoordinates spawn = DimensionPortalData.get(dest) + ChunkCoordinates spawn = PlatformAnchorData.get(dest) .getTarget(); - if (spawn.posY <= 0 || dest.getBlock(spawn.posX, spawn.posY, spawn.posZ) != this) { - spawn = new ChunkCoordinates(0, 65, 0); - } EndOfTimeSourceProperty source = (EndOfTimeSourceProperty) player .getExtendedProperties(EndOfTimeSourceProperty.PROP_KEY); source.entranceWorld = world.provider.dimensionId; source.entranceX = x; source.entranceY = y; source.entranceZ = z; - teleport((EntityPlayerMP) player, dest, spawn.posX, spawn.posY + 1, spawn.posZ); + teleport((EntityPlayerMP) player, dest, spawn.posX, 65, spawn.posZ); } return true; } @@ -157,13 +164,26 @@ private void generateSpawnArea(WorldServer world, int x, int y, int z) { } } - buildPlatform(world, x, y, z); - buildPlatform(world, x + 12, y - 1, z); - buildBridge(world, x + 4, y - 1, z); - buildDock(world, x + 17, y - 1, z); decorate(world, x, y, z); - DimensionPortalData.get(world) - .setTarget(x, y, z); + buildDock(world, x + 17, y - 1, z); + buildBridge(world, x + 4, y - 1, z); + buildPlatform(world, x + 12, y - 1, z); + buildPlatform(world, x, y, z); + + replaceBlock(Blocks.fence, world, x + 8, y, z, Blocks.air, 0, 2); + } + + private static void setBlockIfEmpty(World world, int x, int y, int z, Block blockIn, int metadataIn, int flags) { + if (world.isAirBlock(x, y, z)) { + world.setBlock(x, y, z, blockIn, metadataIn, flags); + } + } + + private static void replaceBlock(Block previous, World world, int x, int y, int z, Block blockIn, int metadataIn, + int flags) { + if (world.getBlock(x, y, z) == previous) { + world.setBlock(x, y, z, blockIn, metadataIn, flags); + } } public static void buildPlatform(World world, int x, int y, int z) { @@ -177,7 +197,7 @@ public static void buildPlatform(World world, int x, int y, int z) { for (int dx = -size / 2; dx <= size / 2; dx++) { for (int dz = -size / 2; dz <= size / 2; dz++) { - world.setBlock(x + dx, yLevel, z + dz, Blocks.stonebrick, 0, 2); + setBlockIfEmpty(world, x + dx, yLevel, z + dz, Blocks.stonebrick, 0, 2); } } @@ -187,111 +207,114 @@ public static void buildPlatform(World world, int x, int y, int z) { int edge = prevSize / 2; // North for (int dx = -edge; dx <= edge - 1; dx++) { - world.setBlock(x + dx, yLevel, z - edge, Blocks.stone_brick_stairs, 6, 2); + setBlockIfEmpty(world, x + dx, yLevel, z - edge, Blocks.stone_brick_stairs, 6, 2); } // East for (int dz = -edge + 1; dz <= edge; dz++) { - world.setBlock(x - edge, yLevel, z + dz, Blocks.stone_brick_stairs, 4, 2); + setBlockIfEmpty(world, x - edge, yLevel, z + dz, Blocks.stone_brick_stairs, 4, 2); } // West for (int dz = -edge; dz <= edge - 1; dz++) { - world.setBlock(x + edge, yLevel, z + dz, Blocks.stone_brick_stairs, 5, 2); + setBlockIfEmpty(world, x + edge, yLevel, z + dz, Blocks.stone_brick_stairs, 5, 2); } // South for (int dx = -edge + 1; dx <= edge; dx++) { - world.setBlock(x + dx, yLevel, z + edge, Blocks.stone_brick_stairs, 7, 2); + setBlockIfEmpty(world, x + dx, yLevel, z + edge, Blocks.stone_brick_stairs, 7, 2); } } } int tipY = y - (halfBase + 1); if (ModBlocks.LAPIS_AETHERIUS.isEnabled()) { - world.setBlock(x, tipY, z, ModBlocks.LAPIS_AETHERIUS.get(), 14, 2); + setBlockIfEmpty(world, x, tipY, z, ModBlocks.LAPIS_AETHERIUS.get(), 14, 2); } else { - world.setBlock(x, tipY, z, Blocks.stonebrick, 0, 2); + setBlockIfEmpty(world, x, tipY, z, Blocks.stonebrick, 0, 2); } // Fence ring // North int topEdge = baseSize / 2; for (int dx = -topEdge; dx <= topEdge; dx++) { - world.setBlock(x + dx, y + 1, z - topEdge, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x + dx, y + 1, z - topEdge, Blocks.fence, 0, 2); } // East for (int dz = -topEdge; dz <= topEdge; dz++) { - world.setBlock(x - topEdge, y + 1, z + dz, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x - topEdge, y + 1, z + dz, Blocks.fence, 0, 2); } // West for (int dz = -topEdge; dz <= topEdge; dz++) { - world.setBlock(x + topEdge, y + 1, z + dz, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x + topEdge, y + 1, z + dz, Blocks.fence, 0, 2); } // South for (int dx = -topEdge; dx <= topEdge; dx++) { - world.setBlock(x + dx, y + 1, z + topEdge, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x + dx, y + 1, z + topEdge, Blocks.fence, 0, 2); } + + replaceBlock(Blocks.fence, world, x + 4, y + 1, z, Blocks.air, 0, 2); } private void buildBridge(World world, int x, int y, int z) { for (int dx = 0; dx < 4; dx++) { for (int dz = -1; dz <= 1; dz++) { - world.setBlock(x + dx, y, z + dz, Blocks.stonebrick, 0, 2); + setBlockIfEmpty(world, x + dx, y, z + dz, Blocks.stonebrick, 0, 2); } } - world.setBlock(x, y + 2, z, Blocks.air, 0, 2); - world.setBlock(x, y + 1, z, Blocks.stone_brick_stairs, 1, 2); + setBlockIfEmpty(world, x, y + 1, z, Blocks.stone_brick_stairs, 1, 2); for (int dx = 1; dx <= 3; dx++) { for (int dz : new int[] { -1, 1 }) { - world.setBlock(x + dx, y + 1, z + dz, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x + dx, y + 1, z + dz, Blocks.fence, 0, 2); if (dx == 1) { - world.setBlock(x + dx, y + 2, z + dz, Blocks.fence, 0, 2); + setBlockIfEmpty(world, x + dx, y + 2, z + dz, Blocks.fence, 0, 2); } } } - - world.setBlock(x + 4, y + 1, z, Blocks.air, 0, 2); } private void buildDock(World world, int x, int y, int z) { for (int dz = -1; dz <= 1; dz++) { - world.setBlock(x, y, z + dz, Blocks.stone_stairs, 5, 2); + setBlockIfEmpty(world, x, y, z + dz, Blocks.stone_stairs, 5, 2); } for (int dz = -1; dz <= 1; dz++) { - world.setBlock(x + 1, y, z + dz, Blocks.stone_slab, 11, 2); + setBlockIfEmpty(world, x + 1, y, z + dz, Blocks.stone_slab, 11, 2); } - world.setBlock(x + 2, y, z - 1, Blocks.stone_stairs, 4, 2); - world.setBlock(x + 2, y, z, Blocks.stone_stairs, 1, 2); - world.setBlock(x + 2, y, z + 1, Blocks.stone_stairs, 4, 2); + setBlockIfEmpty(world, x + 2, y, z - 1, Blocks.stone_stairs, 4, 2); + setBlockIfEmpty(world, x + 2, y, z, Blocks.stone_stairs, 1, 2); + setBlockIfEmpty(world, x + 2, y, z + 1, Blocks.stone_stairs, 4, 2); for (int dx = 0; dx <= 2; dx++) { - world.setBlock(x + dx, y + 1, z - 1, Blocks.cobblestone_wall, 0, 2); - world.setBlock(x + dx, y + 1, z + 1, Blocks.cobblestone_wall, 0, 2); + setBlockIfEmpty(world, x + dx, y + 1, z - 1, Blocks.cobblestone_wall, 0, 2); + setBlockIfEmpty(world, x + dx, y + 1, z + 1, Blocks.cobblestone_wall, 0, 2); } - world.setBlock(x - 1, y + 1, z, Blocks.air, 0, 2); } private void decorate(World world, int x, int y, int z) { + // Always set the portal and the block under it world.setBlock(x, y, z, this, 0, 2); + world.setBlock(x, y - 1, z, Blocks.bedrock, 0, 2); + + // Empty space for the player world.setBlock(x, y + 1, z, Blocks.air, 0, 2); world.setBlock(x, y + 2, z, Blocks.air, 0, 2); + for (int dx = -1; dx <= 1; dx++) { for (int dz = -1; dz <= 1; dz++) { - world.setBlock(x + dx, y - 1, z + dz, Blocks.bedrock, 0, 2); + setBlockIfEmpty(world, x + dx, y - 1, z + dz, Blocks.bedrock, 0, 2); } } for (int dy = 0; dy <= 3; dy++) { - world.setBlock(x + 12, y + dy, z, Blocks.cobblestone_wall, 0, 2); + setBlockIfEmpty(world, x + 12, y + dy, z, Blocks.cobblestone_wall, 0, 2); } - world.setBlock(x + 12, y + 4, z, Blocks.glowstone, 0, 2); - world.setBlock(x + 12, y + 5, z, Blocks.stone_slab, 3, 2); - world.setBlock(x + 15, y, z - 3, Blocks.cauldron, 3, 2); - world.setBlock(x + 15, y, z - 2, Blocks.flower_pot, 0, 2); + setBlockIfEmpty(world, x + 12, y + 4, z, Blocks.glowstone, 0, 3); + setBlockIfEmpty(world, x + 12, y + 5, z, Blocks.stone_slab, 3, 2); + setBlockIfEmpty(world, x + 15, y, z - 3, Blocks.cauldron, 3, 2); + setBlockIfEmpty(world, x + 15, y, z - 2, Blocks.flower_pot, 0, 2); TileEntity tileEntity = world.getTileEntity(x + 15, y, z - 2); if (tileEntity instanceof TileEntityFlowerPot pot) { pot.func_145964_a((Item) Item.itemRegistry.getObject("sapling"), 0); } - world.setBlock(x + 9, y, z + 3, Blocks.flower_pot, 0, 2); + setBlockIfEmpty(world, x + 9, y, z + 3, Blocks.flower_pot, 0, 2); tileEntity = world.getTileEntity(x + 9, y, z + 3); if (tileEntity instanceof TileEntityFlowerPot pot) { pot.func_145964_a((Item) Item.itemRegistry.getObject("sapling"), 0); diff --git a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/DimensionPortalData.java b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/PlatformAnchorData.java similarity index 65% rename from src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/DimensionPortalData.java rename to src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/PlatformAnchorData.java index 17dc61237..bb2a697f9 100644 --- a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/DimensionPortalData.java +++ b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/PlatformAnchorData.java @@ -6,26 +6,26 @@ import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; -public class DimensionPortalData extends WorldSavedData { +public class PlatformAnchorData extends WorldSavedData { - public static final String DATA_NAME = "PortalTarget"; + public static final String DATA_NAME = "PlatformAnchor"; private int x, y, z; - static DimensionPortalData INSTANCE; + static PlatformAnchorData INSTANCE; - public DimensionPortalData() { + public PlatformAnchorData() { this(DATA_NAME); } - public DimensionPortalData(String tagName) { + public PlatformAnchorData(String tagName) { super(tagName); } - public static DimensionPortalData get(World world) { + public static PlatformAnchorData get(World world) { MapStorage storage = world.perWorldStorage; - DimensionPortalData.INSTANCE = (DimensionPortalData) storage - .loadData(DimensionPortalData.class, DimensionPortalData.DATA_NAME); + PlatformAnchorData.INSTANCE = (PlatformAnchorData) storage + .loadData(PlatformAnchorData.class, PlatformAnchorData.DATA_NAME); if (INSTANCE == null) { - INSTANCE = new DimensionPortalData(DATA_NAME); + INSTANCE = new PlatformAnchorData(DATA_NAME); storage.setData(DATA_NAME, INSTANCE); } return INSTANCE; @@ -42,6 +42,10 @@ public ChunkCoordinates getTarget() { return new ChunkCoordinates(x, y, z); } + public boolean isZero() { + return x == 0 && y == 0 && z == 0; + } + @Override public void readFromNBT(NBTTagCompound nbt) { x = nbt.getInteger("X"); diff --git a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/WorldProviderEndOfTime.java b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/WorldProviderEndOfTime.java index 09ec3ccef..faffb2c30 100644 --- a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/WorldProviderEndOfTime.java +++ b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/dimensions/endoftime/WorldProviderEndOfTime.java @@ -5,6 +5,7 @@ import net.minecraft.util.Vec3; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.event.world.WorldEvent; @@ -22,7 +23,7 @@ public class WorldProviderEndOfTime extends WorldProvider { public void registerWorldChunkManager() { this.worldChunkMgr = new UIEWorldChunkManager(BiomeGenBase.getBiome(EndOfTimeConfig.INSTANCE.defaultBiomeId)); this.dimensionId = EndOfTimeConfig.INSTANCE.endOfTimeDimensionId; - this.hasNoSky = true; + this.hasNoSky = false; } @Override @@ -32,7 +33,7 @@ public IChunkProvider createChunkGenerator() { @Override public float calculateCelestialAngle(long p_76563_1_, float p_76563_3_) { - return 0.0F; + return 0.5F; } @Override @@ -44,9 +45,10 @@ public float[] calcSunriseSunsetColors(float p_76560_1_, float p_76560_2_) { @Override @SideOnly(Side.CLIENT) public boolean isSkyColored() { - return false; + return true; } + @Override @SideOnly(Side.CLIENT) public Vec3 getSkyColor(Entity p_72833_1_, float p_72833_2_) { return Vec3.createVectorHelper(0, 0, 0); @@ -83,8 +85,29 @@ public boolean canCoordinateBeSpawn(int x, int z) { @Override public ChunkCoordinates getEntrancePortalLocation() { - return DimensionPortalData.get(this.worldObj) - .getTarget(); + PlatformAnchorData data = PlatformAnchorData.get(this.worldObj); + return data.isZero() ? new ChunkCoordinates(0, 65, 0) : data.getTarget(); + } + + @Override + public boolean isDaytime() { + return false; + } + + @Override + public void calculateInitialWeather() {} + + @Override + public void updateWeather() {} + + @Override + public boolean canDoLightning(Chunk chunk) { + return false; + } + + @Override + public boolean canDoRainSnowIce(Chunk chunk) { + return false; } @Override From 24ccc937dbc70293cd38aa7e12735af01946cec4 Mon Sep 17 00:00:00 2001 From: SuperSoupr <26164930+SuperSoupr@users.noreply.github.com> Date: Thu, 16 Jul 2026 01:36:47 +0300 Subject: [PATCH 2/2] typo --- .../utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java index 46a86d54d..e53590f05 100644 --- a/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java +++ b/src/main/java/com/fouristhenumber/utilitiesinexcess/common/blocks/BlockPortalEndOfTime.java @@ -110,7 +110,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p .worldServerForDimension(EndOfTimeConfig.INSTANCE.endOfTimeDimensionId); // Extra Utilities has it's End of Time equivalent's platform generate at world spawn, so we replicate that // behavior for compatibility with older saves. - // However, this lead to a bug causing the platform to generate multiple times if world spawn was ever + // However, this led to a bug causing the platform to generate multiple times if world spawn was ever // changed, so anchor it the first time we're loaded. if (PlatformAnchorData.get(dest) .isZero()) {