From 6eacd2d62fb638b52ef455d9848e6db5f8c05a11 Mon Sep 17 00:00:00 2001 From: Waterpicker <Waterpickerenternity@gmail.com> Date: Wed, 25 Jan 2017 15:25:03 -0600 Subject: [PATCH 1/2] Not done. Just pushing current code. --- .../com/zixiken/dimdoors/DDProxyCommon.java | 2 + .../dimdoors/client/CloudRenderBlank.java | 17 + .../zixiken/dimdoors/shared/PocketPlacer.java | 1 + .../dimdoors/shared/SchematicHandler.java | 9 + .../dimdoors/shared/TeleportHelper.java | 6 + .../dimdoors/world/BiomeGenPocket.java | 7 + .../dimdoors/world/CustomSkyProvider.java | 210 +++++++++++ .../dimdoors/world/DimDoorDimensions.java | 23 ++ .../dimdoors/world/PocketGenerator.java | 62 ++++ .../dimdoors/world/PocketProvider.java | 22 -- .../dimdoors/world/biomes/DimDoorsBiome.java | 26 ++ .../dimdoors/world/limbo/LimboBiome.java | 12 + .../dimdoors/world/limbo/LimboDecay.java | 173 +++++++++ .../dimdoors/world/limbo/LimboGenerator.java | 337 ++++++++++++++++++ .../world/limbo/LimboSkyProvider.java | 21 ++ .../world/limbo/WorldProviderLimbo.java | 149 ++++++++ .../WorldProviderPersonalPocket.java | 7 + .../world/pocket/PocketSkyProvider.java | 20 ++ .../world/pocket/WorldProviderPocket.java | 12 + 19 files changed, 1094 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/BiomeGenPocket.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/CustomSkyProvider.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java delete mode 100644 src/main/java/com/zixiken/dimdoors/world/PocketProvider.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/biomes/DimDoorsBiome.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/limbo/LimboSkyProvider.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/pocket/PocketSkyProvider.java create mode 100644 src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java diff --git a/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java b/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java index a252ea6e..0c7cde86 100644 --- a/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java +++ b/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java @@ -8,6 +8,7 @@ import com.zixiken.dimdoors.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.tileentities.TileEntityDimDoorGold; import com.zixiken.dimdoors.tileentities.TileEntityRift; import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor; +import com.zixiken.dimdoors.world.DimDoorDimensions; import net.minecraft.block.BlockDoor; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; @@ -21,6 +22,7 @@ public abstract class DDProxyCommon implements IDDProxy { @Override public void onPreInitialization(FMLPreInitializationEvent event) { + DimDoorDimensions.init(); ModBlocks.registerBlocks(); ModItems.registerItems(); diff --git a/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java b/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java new file mode 100644 index 00000000..dbf09417 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/client/CloudRenderBlank.java @@ -0,0 +1,17 @@ +package com.zixiken.dimdoors.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class CloudRenderBlank extends IRenderHandler +{ + @Override + @SideOnly(Side.CLIENT) + public void render(float partialTicks, WorldClient world, Minecraft mc) + { + + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/shared/PocketPlacer.java b/src/main/java/com/zixiken/dimdoors/shared/PocketPlacer.java index 5de22ba6..bf76d526 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/PocketPlacer.java +++ b/src/main/java/com/zixiken/dimdoors/shared/PocketPlacer.java @@ -22,6 +22,7 @@ class PocketPlacer { //there is exactly one pocket placer for each different sch int place(int x, int y, int z, int dimID) { //actual coords //@todo generate a "bedrock" wall around the pocket and start generating the contents of the pocket at (1, 0, 1) //so pocket with size 1 is 14 * 14, size 2 is 30 * 30, size 3 is 46 * 46 etc. + return 0; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java b/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java index 06698a12..b26492f0 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java +++ b/src/main/java/com/zixiken/dimdoors/shared/SchematicHandler.java @@ -6,8 +6,16 @@ package com.zixiken.dimdoors.shared; import com.zixiken.dimdoors.DDConfig; +import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.CompressedStreamTools; + import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @@ -53,6 +61,7 @@ public class SchematicHandler { private PocketPlacer loadSchematic(String nameString, int maxPocketSize) { //check for json files in both directories (inside the mod jar, and inside the dimdoors config folder) //check if the json has a "variant" with the correct pocket size, if it doesn't, pick the largest smaller variant. If there's only bigger variants, cancel + return null; } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java b/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java index 8d4925cd..47e63b58 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java +++ b/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java @@ -1,6 +1,8 @@ package com.zixiken.dimdoors.shared; import com.zixiken.dimdoors.DimDoors; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -24,6 +26,10 @@ public class TeleportHelper extends Teleporter { entityIn.setPositionAndUpdate(pos.getX() + .5, pos.getY() + .05, pos.getZ() + .5); } + public IBlockState toBlockState(String id) { + String[] list = id.split("["); + } + public static boolean teleport(Entity entity, Location newLocation) { if (DimDoors.isClient()) { //DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP."); diff --git a/src/main/java/com/zixiken/dimdoors/world/BiomeGenPocket.java b/src/main/java/com/zixiken/dimdoors/world/BiomeGenPocket.java new file mode 100644 index 00000000..dd3dbb88 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/BiomeGenPocket.java @@ -0,0 +1,7 @@ +package com.zixiken.dimdoors.world; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class BiomeGenPocket { +} diff --git a/src/main/java/com/zixiken/dimdoors/world/CustomSkyProvider.java b/src/main/java/com/zixiken/dimdoors/world/CustomSkyProvider.java new file mode 100644 index 00000000..906df88c --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/CustomSkyProvider.java @@ -0,0 +1,210 @@ +package com.zixiken.dimdoors.world; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + +public class CustomSkyProvider extends IRenderHandler { + + int starGLCallList; + int glSkyList; + int glSkyList2; + private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png"); + + + public ResourceLocation getMoonRenderPath() { + return null; + } + + public ResourceLocation getSunRenderPath() { + return null; + } + + + @SideOnly(Side.CLIENT) + @Override + public void render(float par1, WorldClient world, Minecraft mc) { + + starGLCallList = GLAllocation.generateDisplayLists(3); + glSkyList = this.starGLCallList + 1; + glSkyList2 = this.starGLCallList + 2; + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.disableStandardItemLighting(); + GL11.glDepthMask(false); + + mc.renderEngine.bindTexture((locationEndSkyPng)); + + if (world.provider.isSurfaceWorld()) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3d vec3 = world.getSkyColor(mc.getRenderViewEntity(), par1); + float f1 = (float) vec3.xCoord; + float f2 = (float) vec3.yCoord; + float f3 = (float) vec3.zCoord; + float f4; + + GL11.glColor3f(f1, f2, f3); + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + + GlStateManager.depthMask(false); + GlStateManager.enableFog(); + GlStateManager.color(f1, f2, f3); + GlStateManager.callList(this.glSkyList); + GlStateManager.disableFog(); + GlStateManager.disableAlpha(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.disableStandardItemLighting(); + + float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1); + float f7; + float f8; + float f9; + float f10; + + if (afloat != null) { + GlStateManager.disableTexture2D(); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + GlStateManager.pushMatrix(); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(MathHelper.sin(world.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); + f4 = afloat[0]; + f7 = afloat[1]; + f8 = afloat[2]; + float f11; + + buffer.begin(6, DefaultVertexFormats.POSITION_COLOR); + + buffer.pos(0d, 100d, 0d).color(f4, f7, f8, afloat[3]).endVertex(); + + byte b0 = 16; + + for (int j = 0; j <= b0; ++j) { + f11 = j * (float) Math.PI * 2.0F / b0; + float f12 = MathHelper.sin(f11); + float f13 = MathHelper.cos(f11); + + buffer.pos(f12 * 120.0F, f13 * 120.0F, -f13 * 40.0F * afloat[3]).color(afloat[0], afloat[1], afloat[2], 0.0f).endVertex(); + } + + tessellator.draw(); + GlStateManager.popMatrix(); + GlStateManager.shadeModel(GL11.GL_FLAT); + } + + GlStateManager.enableTexture2D(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GlStateManager.pushMatrix(); + + f4 = 1.0F - world.getRainStrength(par1); + f7 = 0.0F; + f8 = 0.0F; + f9 = 0.0F; + GlStateManager.color(1.0F, 1.0F, 1.0F, f4); + GlStateManager.translate(f7, f8, f9); + GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(world.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F); + + f10 = 30.0F; + mc.renderEngine.bindTexture(this.getSunRenderPath()); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-f10, 100.0D, -f10).tex(0.0D, 0.0D).endVertex(); + buffer.pos(f10, 100.0D, -f10).tex(1.0D, 0.0D).endVertex(); + buffer.pos(f10, 100.0D, f10).tex(1.0D, 1.0D).endVertex(); + buffer.pos(-f10, 100.0D, f10).tex(0.0D, 1.0D).endVertex(); + tessellator.draw(); + + f10 = 20.0F; + mc.renderEngine.bindTexture(this.getMoonRenderPath()); + int k = world.getMoonPhase(); + int l = k % 4; + int i1 = k / 4 % 2; + float f14 = l + 0; + float f15 = i1 + 0; + float f16 = l + 1; + float f17 = i1 + 1; + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-f10, -100.0D, f10).tex(f16, f17).endVertex(); + buffer.pos(f10, -100.0D, f10).tex(f14, f17).endVertex(); + buffer.pos(f10, -100.0D, -f10).tex(f14, f15).endVertex(); + buffer.pos(-f10, -100.0D, -f10).tex(f16, f15).endVertex(); + tessellator.draw(); + GlStateManager.disableTexture2D(); + float f18 = world.getStarBrightness(par1) * f4; + + if (f18 > 0.0F) { + GlStateManager.color(f18, f18, f18, f18); + GlStateManager.callList(this.starGLCallList); + } + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableFog(); + GlStateManager.popMatrix(); + GlStateManager.disableTexture2D(); + GlStateManager.color(0.0F, 0.0F, 0.0F); + double d0 = mc.player.getPosition().getY() - world.getHorizon(); + + if (d0 < 0.0D) { + GlStateManager.pushMatrix(); + GlStateManager.translate(0.0F, 12.0F, 0.0F); + GlStateManager.callList(this.glSkyList2); + GlStateManager.popMatrix(); + f8 = 1.0F; + f9 = -((float) (d0 + 65.0D)); + f10 = -f8; + + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + buffer.pos(-f8, f9, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f9, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, -f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, -f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f9, -f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f9, -f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, -f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f9, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f9, -f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f9, -f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f9, f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, -f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, -f8).color(0,0,0,1).endVertex(); + buffer.pos(-f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, f8).color(0,0,0,1).endVertex(); + buffer.pos(f8, f10, -f8).color(0,0,0,1).endVertex(); + tessellator.draw(); + } + + if (world.provider.isSkyColored()) { + GlStateManager.color(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F); + } else { + GlStateManager.color(f1, f2, f3); + } + + GlStateManager.pushMatrix(); + GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F); + GlStateManager.callList(this.glSkyList2); + GlStateManager.popMatrix(); + GlStateManager.enableTexture2D(); + GlStateManager.depthMask(true); + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java b/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java new file mode 100644 index 00000000..65bc4e78 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java @@ -0,0 +1,23 @@ +package com.zixiken.dimdoors.world; + +import com.zixiken.dimdoors.world.limbo.WorldProviderLimbo; +import com.zixiken.dimdoors.world.pocket.WorldProviderPocket; +import net.minecraft.world.DimensionType; +import net.minecraftforge.common.DimensionManager; + +public class DimDoorDimensions { + public static DimensionType LIMBO; + public static DimensionType POCKET; + + public static void init() { + LIMBO = DimensionType.register("Limbo", "_limbo", DimensionManager.getNextFreeDimId(), WorldProviderPocket.class, false); + POCKET = DimensionType.register("Pocket", "_pocket", DimensionManager.getNextFreeDimId(), WorldProviderLimbo.class, false); + + registerDimension(LIMBO); + registerDimension(POCKET); + } + + public static void registerDimension(DimensionType dimension) { + DimensionManager.registerDimension(dimension.getId(), dimension); + } +} diff --git a/src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java b/src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java new file mode 100644 index 00000000..afc5ef50 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java @@ -0,0 +1,62 @@ +package com.zixiken.dimdoors.world; + +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunkGenerator; + +import javax.annotation.Nullable; +import java.util.List; + +public class PocketGenerator implements IChunkGenerator { + private World worldObj; + + //private CustomLimboPopulator spawner; + + public PocketGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { + this.worldObj = world; + + //this.spawner = spawner; + } + + @Override + public Chunk provideChunk(int chunkX, int chunkZ) { + ChunkPrimer primer = new ChunkPrimer(); + Chunk chunk = new Chunk(worldObj, primer, chunkX, chunkZ); + + if(!chunk.isTerrainPopulated()) { + chunk.setTerrainPopulated(true); + //spawner.registerChunkForPopulation(worldObj.provider.dimensionId, chunkX, chunkZ); + } + return chunk; + } + + @Override + public void populate(int chunkX, int chunkZ) { + + } + + @Override + public boolean generateStructures(Chunk chunkIn, int x, int z) { + return false; + } + + @Override + public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { + return null; + } + + @Nullable + @Override + public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position) { + return null; + } + + @Override + public void recreateStructures(Chunk chunkIn, int x, int z) { + + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/PocketProvider.java b/src/main/java/com/zixiken/dimdoors/world/PocketProvider.java deleted file mode 100644 index 2954362c..00000000 --- a/src/main/java/com/zixiken/dimdoors/world/PocketProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.zixiken.dimdoors.world; - -import net.minecraft.world.DimensionType; -import net.minecraft.world.WorldProvider; - -public class PocketProvider extends WorldProvider { - - /*@Override - public String getDimensionName() { - return "Pocket Dimension"; - } - - @Override - public String getInternalNameSuffix() { - return "_pocket"; - }*/ - - @Override - public DimensionType getDimensionType() { - return DimensionType.OVERWORLD; - } -} diff --git a/src/main/java/com/zixiken/dimdoors/world/biomes/DimDoorsBiome.java b/src/main/java/com/zixiken/dimdoors/world/biomes/DimDoorsBiome.java new file mode 100644 index 00000000..37b47bae --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/biomes/DimDoorsBiome.java @@ -0,0 +1,26 @@ +package com.zixiken.dimdoors.world.biomes; + +import net.minecraft.world.biome.Biome; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class DimDoorsBiome extends Biome +{ + public DimDoorsBiome(String name) { + super(new BiomeProperties(name)); + this.theBiomeDecorator.treesPerChunk = 0; + this.theBiomeDecorator.flowersPerChunk = 0; + this.theBiomeDecorator.grassPerChunk = 0; + + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); + } + + @Override + public boolean canRain() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java new file mode 100644 index 00000000..cddb0ebc --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java @@ -0,0 +1,12 @@ +package com.zixiken.dimdoors.world.limbo; + +import com.zixiken.dimdoors.world.biomes.DimDoorsBiome; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class LimboBiome extends DimDoorsBiome { + public LimboBiome() { + super("limbo"); + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java new file mode 100644 index 00000000..cfb5bb37 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java @@ -0,0 +1,173 @@ +package com.zixiken.dimdoors.world.limbo; + +import com.zixiken.dimdoors.blocks.BlockDimWall; +import com.zixiken.dimdoors.blocks.ModBlocks; +import com.zixiken.dimdoors.world.DimDoorDimensions; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.ForgeChunkManager; + +import java.util.Random; + +/** + * Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo + * naturally change into stone, then cobble, then gravel, and finally Unraveled Fabric as time passes. + */ +public class LimboDecay { + + private static final int MAX_DECAY_SPREAD_CHANCE = 100; + private static final int DECAY_SPREAD_CHANCE = 50; + private static final int CHUNK_SIZE = 16; + private static final int SECTION_HEIGHT = 16; + + //Provides a reversed list of the block IDs that blocks cycle through during decay. + private static IBlockState[] decaySequence = null; + + private static final Random random = new Random(); + private static IBlockState[] blocksImmuneToDecay = null; + + public static IBlockState[] getDecaySequence() { + if (decaySequence == null) { + decaySequence = new IBlockState[] { + mod_pocketDim.blockLimbo, + Blocks.GRAVEL.getDefaultState(), + Blocks.COBBLESTONE.getDefaultState(), + Blocks.STONE.getDefaultState() + }; + } + + return decaySequence; + } + + public static IBlockState[] getBlocksImmuneToDecay() { + if (blocksImmuneToDecay == null) { + blocksImmuneToDecay = new IBlockState[] { + mod_pocketDim.blockLimbo, + ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ANCIENT), + ModBlocks.blockDimDoorTransient.getDefaultState(), + ModBlocks.blockDimDoor.getDefaultState(), + ModBlocks.blockDimDoorWarp.getDefaultState(), + ModBlocks.blockRift.getDefaultState(), + ModBlocks.blockDimDoorChaos.getDefaultState(), + ModBlocks.blockDoorGold, + ModBlocks.blockDoorQuartz, + ModBlocks.blockDimDoorGold + }; + } + + return blocksImmuneToDecay; + } + + /** + * Checks the blocks orthogonally around a given location (presumably the location of an Unraveled Fabric block) + * and applies Limbo decay to them. This gives the impression that decay spreads outward from Unraveled Fabric. + */ + public void applySpreadDecay(World world, BlockPos pos) + { + //Check if we randomly apply decay spread or not. This can be used to moderate the frequency of + //full spread decay checks, which can also shift its performance impact on the game. + if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE) { + //Apply decay to the blocks above, below, and on all four sides. + //World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world + decayBlock(world, pos.up()); + decayBlock(world, pos.down()); + decayBlock(world, pos.north()); + decayBlock(world, pos.south()); + decayBlock(world, pos.west()); + decayBlock(world, pos.east()); + } + } + + /** + * Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric. + * This decay method is designed to stop players from avoiding Limbo decay by building floating structures. + */ + public void applyRandomFastDecay() + { + int x, y, z; + int sectionY; + int limboHeight; + int[] limbo = DimensionManager.getDimensions(DimDoorDimensions.LIMBO); + + + for (Integer i : limbo){ + World world = DimensionManager.getWorld(i); + + limboHeight = world.getHeight(); + + //Obtain the coordinates of active chunks in Limbo. For each section of each chunk, + //pick a random block and try to apply fast decay. + for (ChunkPos chunkPos : ForgeChunkManager.getPersistentChunksFor(world).keySet()) { + //Loop through each chunk section and fast-decay a random block + //Apply the changes using the world object instead of directly to the chunk so that clients are always notified. + for (sectionY = 0; sectionY < limboHeight; sectionY += SECTION_HEIGHT) { + BlockPos pos = new BlockPos(chunkPos.chunkXPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), + chunkPos.chunkZPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), + sectionY + random.nextInt(SECTION_HEIGHT)); + decayBlockFast(world, pos); + } + } + } + } + + /** + * Checks if a block can be decayed and, if so, changes it directly into Unraveled Fabric. + */ + private boolean decayBlockFast(World world, BlockPos pos) { + IBlockState block = world.getBlockState(pos); + if (canDecayBlock(block, world, pos)) { + world.setBlockState(pos, mod_pocketDim.blockLimbo); + return true; + } + return false; + } + + /** + * Checks if a block can be decayed and, if so, changes it to the next block ID along the decay sequence. + */ + private boolean decayBlock(World world, BlockPos pos) { + int index; + IBlockState block = world.getBlockState(pos); + if (canDecayBlock(block, world, pos)) { + //Loop over the block IDs that decay can go through. + //Find an index matching the current blockID, if any. + for (index = 0; index < getDecaySequence().length; index++) { + if (getDecaySequence()[index].equals(block)) { + break; + } + } + + //Since the decay sequence is a reversed list, the block ID in the index before our match + //is the block ID we should change this block into. A trick in this approach is that if + //we loop over the array without finding a match, then (index - 1) will contain the + //last ID in the array, which is the first one that all blocks decay into. + //We assume that Unraveled Fabric is NOT decayable. Otherwise, this will go out of bounds! + + world.setBlockState(pos, getDecaySequence()[index - 1]); + return true; + } + return false; + } + + /** + * Checks if a block can decay. We will not decay air, certain DD blocks, or containers. + */ + private boolean canDecayBlock(IBlockState block, World world, BlockPos pos) { + if (world.isAirBlock(pos )) { + return false; + } + + for (int k = 0; k < getBlocksImmuneToDecay().length; k++) { + if (block.equals(getBlocksImmuneToDecay()[k])) { + return false; + } + } + + return (block == null || !(block instanceof BlockContainer)); + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java new file mode 100644 index 00000000..fb6d845d --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java @@ -0,0 +1,337 @@ +package com.zixiken.dimdoors.world.limbo; + +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Biomes; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraft.world.gen.NoiseGeneratorOctaves; +import net.minecraft.world.gen.structure.MapGenScatteredFeature; +import net.minecraftforge.common.BiomeManager; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.Random; + +public class LimboGenerator implements IChunkGenerator +{ + private static Random rand; + + /** A NoiseGeneratorOctaves used in generating terrain */ + private NoiseGeneratorOctaves noiseGen1; + + /** A NoiseGeneratorOctaves used in generating terrain */ + private NoiseGeneratorOctaves noiseGen2; + + /** A NoiseGeneratorOctaves used in generating terrain */ + private NoiseGeneratorOctaves noiseGen3; + + /** A NoiseGeneratorOctaves used in generating terrain */ + private NoiseGeneratorOctaves noiseGen4; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen5; + + public World world; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen6; + public NoiseGeneratorOctaves mobSpawnerNoise; + + /** Reference to the World object. */ + private World worldObj; + + /** Holds the overall noise array used in chunk generation */ + private double[] noiseArray; + + private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + + /** The biomes that are used to generate the chunk */ + private Biome[] biomesForGeneration = new Biome[1]; + + /** A double array that hold terrain noise from noiseGen3 */ + double[] noise3; + + /** A double array that hold terrain noise */ + double[] noise1; + + /** A double array that hold terrain noise from noiseGen2 */ + double[] noise2; + + /** A double array that hold terrain noise from noiseGen5 */ + double[] noise5; + + /** A double array that holds terrain noise from noiseGen6 */ + double[] noise6; + + /** + * Used to store the 5x5 parabolic field that is used during terrain generation. + */ + float[] parabolicField; + int[][] field_73219_j = new int[32][32]; + { + // caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); + } + //private CustomLimboPopulator spawner; + + public LimboGenerator(World world, long seed, /*CustomLimboPopulator spawner*/) { + this.worldObj = world; + BiomeManager + LimboGenerator.rand = new Random(seed); + this.noiseGen1 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //base terrain + this.noiseGen2 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //hillyness + this.noiseGen3 = new NoiseGeneratorOctaves(LimboGenerator.rand, 80); //seems to adjust the size of features, how stretched things are -default 8 + this.noiseGen4 = new NoiseGeneratorOctaves(LimboGenerator.rand, 4); + this.noiseGen5 = new NoiseGeneratorOctaves(LimboGenerator.rand, 10); + this.noiseGen6 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); + this.mobSpawnerNoise = new NoiseGeneratorOctaves(LimboGenerator.rand, 8); + + NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise}; + // noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); + this.noiseGen1 = noiseGens[0]; + this.noiseGen2 = noiseGens[1]; + this.noiseGen3 = noiseGens[2]; + this.noiseGen4 = noiseGens[3]; + this.noiseGen5 = noiseGens[4]; + this.noiseGen6 = noiseGens[5]; + this.mobSpawnerNoise = noiseGens[6]; + + this.worldObj = world; + + this.spawner = spawner; + } + + @Override + public Chunk provideChunk(int chunkX, int chunkZ) + { + //TODO: Wtf? Why do you reinitialize the seed when we already initialized it in the constructor?! ~SenseiKiwi + LimboGenerator.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L); + ChunkPrimer primer = new ChunkPrimer(); + this.setBlocksInChunk(chunkX, chunkZ, primer); + Chunk chunk = new Chunk(this.worldObj, primer, chunkX, chunkZ); + chunk.generateSkylightMap(); + + if (!chunk.isTerrainPopulated()) { + chunk.setTerrainPopulated(true); + //spawner.registerChunkForPopulation(properties.LimboDimensionID, chunkX, chunkZ); + } + + return chunk; + } + + @Override + public void populate(int var2, int var3) { + + } + + @Override + public boolean generateStructures(Chunk chunkIn, int x, int z) { + return false; + } + + private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) { + if (par1ArrayOfDouble == null) { + par1ArrayOfDouble = new double[par5 * par6 * par7]; + } + + if (this.parabolicField == null) { + this.parabolicField = new float[25]; + + for (int var8 = -2; var8 <= 2; ++var8) { + for (int var9 = -2; var9 <= 2; ++var9) { + float var10 = 10.0F / MathHelper.sqrt(var8 * var8 + var9 * var9 + 0.2F); + this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10; + } + } + } + + double var44 = 884.412D; //large values here create spiky land. add a 0, good -default 884 + double var45 = 9840.412D; //large values here make sheets- default - 684 + this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D); + this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D); + this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D); + this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44); + this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44); + + int var12 = 0; + int var13 = 0; + + for (int var14 = 0; var14 < par5; ++var14) { + for (int var15 = 0; var15 < par7; ++var15) { + float var16 = 0.0F; + float var17 = 0.0F; + float var18 = 0.0F; + byte var19 = 2; + + for (int var21 = -var19; var21 <= var19; ++var21) { + for (int var22 = -var19; var22 <= var19; ++var22) { + float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (Biomes.PLAINS.getBaseHeight() + 9.0F); + + + //this adjusts the height of the terrain + + var16 += Biomes.PLAINS.getHeightVariation() * var24+4; + var17 += Biomes.PLAINS.getBaseHeight() * var24-1; + var18 += var24; + } + } + + var16 /= var18; + var17 /= var18; + var16 = (var16 * 0.9F + 0.1F); + var17 = (var17 * 4.0F - 1.0F) / 8.0F; + double var47 = this.noise6[var13] / 8000.0D; + + if (var47 < 0.0D) { + var47 = -var47 * 0.3D; + } + + var47 = var47 * 3.0D - 2.0D; + + if (var47 < 0.0D) { + var47 /= 2.0D; + + if (var47 < -1.0D) { + var47 = -1.0D; + } + + var47 /= 1.4D; + var47 /= 2.0D; + } + else { + if (var47 > 1.0D) { + var47 = 1.0D; + } + + var47 /= 8.0D; + } + + ++var13; + + for (int var46 = 0; var46 < par6; ++var46) { + double var48 = var17; + double var26 = var16; + var48 += var47 * 0.2D; + var48 = var48 * par6 / 16.0D; + double var28 = par6 / 2.0D + var48 * 4.0D; + double var30 = 0.0D; + double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26; + + if (var32 < 0.0D) { + var32 *= 4.0D; + } + + double var34 = this.noise1[var12] / 512.0D; + double var36 = this.noise2[var12] / 512.0D; + double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D; + + if (var38 < 0.0D) { + var30 = var34; + } + else if (var38 > 1.0D) { + var30 = var36; + } + else { + var30 = var34 + (var36 - var34) * var38; + } + + var30 -= var32; + + if (var46 > par6 - 4) { + double var40 = (var46 - (par6 - 4)) / 3.0F; + var30 = var30 * (1.0D - var40) + -10.0D * var40; + } + + par1ArrayOfDouble[var12] = var30; + ++var12; + } + } + } + + return par1ArrayOfDouble; + } + + public void setBlocksInChunk(int x, int z, ChunkPrimer blocks) { + byte var4 = 4; + byte var5 = 16; + byte var6 = 19; + int var7 = var4 + 1; + byte var8 = 17; + int var9 = var4 + 1; + this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, var7 + 5, var9 + 5); + this.noiseArray = this.initializeNoiseField(this.noiseArray, x * var4, 0, z * var4, var7, var8, var9); + + for (int var10 = 0; var10 < var4; ++var10) { + for (int var11 = 0; var11 < var4; ++var11) { + for (int var12 = 0; var12 < var5; ++var12) { + double var13 = 0.125D; + double var15 = this.noiseArray[((((var10) * var9) + var11) * var8) + var12]; + double var17 = this.noiseArray[((var10) * var9 + var11 + 1) * var8 + var12]; + double var19 = this.noiseArray[((var10 + 1) * var9 + var11) * var8 + var12]; + double var21 = this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12]; + double var23 = (this.noiseArray[((var10) * var9 + var11) * var8 + var12 + 1] - var15) * var13; + double var25 = (this.noiseArray[((var10) * var9 + var11 + 1) * var8 + var12 + 1] - var17) * var13; + double var27 = (this.noiseArray[((var10 + 1) * var9 + var11) * var8 + var12 + 1] - var19) * var13; + double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13; + + for (int var31 = 0; var31 < 8; ++var31) { + double var32 = 0.25D; + double var34 = var15; + double var36 = var17; + double var38 = (var19 - var15) * var32; + double var40 = (var21 - var17) * var32; + + for (int var42 = 0; var42 < 4; ++var42) { + int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31; + short var44 = 128; + var43 -= var44; + double var45 = 0.25D; + double var49 = (var36 - var34) * var45; + double var47 = var34 - var49; + + for (int var51 = 0; var51 < 4; ++var51) { + if ((var47 += var49) > 0.0D) { + blocks[var43 += var44] = mod_pocketDim.blockLimbo; + } else if (var12 * 8 + var31 < var6) { + blocks[var43 += var44] = mod_pocketDim.blockDimWallPerm; + } else { + blocks[var43 += var44] = Blocks.air; + } + } + + var34 += var38; + var36 += var40; + } + + var15 += var23; + var17 += var25; + var19 += var27; + var21 += var29; + } + } + } + } + } + + @Override + public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType par1EnumCreatureType, BlockPos pos) { + + Biome biomegenbase = this.worldObj.getBiomeForCoordsBody(pos); + return biomegenbase == Biomes.SWAMPLAND && par1EnumCreatureType == EnumCreatureType.MONSTER && this.scatteredFeatureGenerator.isInsideStructure(pos) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + @Nullable + @Override + public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position) { + return null; + } + + @Override + public void recreateStructures(Chunk chunkIn, int x, int z) { + + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboSkyProvider.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboSkyProvider.java new file mode 100644 index 00000000..a3dee9cb --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboSkyProvider.java @@ -0,0 +1,21 @@ +package com.zixiken.dimdoors.world.limbo; + +import com.zixiken.dimdoors.world.CustomSkyProvider; +import net.minecraft.util.ResourceLocation; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class LimboSkyProvider extends CustomSkyProvider +{ + @Override + public ResourceLocation getMoonRenderPath() + { + return new ResourceLocation("DimDoors:textures/other/limboMoon.png"); + } + + @Override + public ResourceLocation getSunRenderPath() { + return new ResourceLocation("DimDoors:textures/other/limboSun.png"); + } +} \ No newline at end of file diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java b/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java new file mode 100644 index 00000000..99faf435 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java @@ -0,0 +1,149 @@ +package com.zixiken.dimdoors.world.limbo; + +import com.zixiken.dimdoors.client.CloudRenderBlank; +import com.zixiken.dimdoors.shared.Location; +import com.zixiken.dimdoors.world.DimDoorDimensions; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.DimensionType; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class WorldProviderLimbo extends WorldProvider { + private IRenderHandler skyRenderer; + private CustomLimboPopulator spawner; + + public WorldProviderLimbo() { + this.hasNoSky = false; + this.skyRenderer = new LimboSkyProvider(); + //this.spawner + } + + @Override + @SideOnly(Side.CLIENT) + public IRenderHandler getSkyRenderer() { + return skyRenderer; + } + + @Override + public Biome getBiomeForCoords(BlockPos pos) { + return new LimboBiome(); + } + + @Override + public boolean canRespawnHere() + { + return false; //properties.HardcoreLimboEnabled; + } + + @Override + public boolean isBlockHighHumidity(BlockPos pos) + { + return false; + } + + @Override + public boolean canSnowAt(BlockPos pos, boolean checkLight) { + return false; + } + + @Override + protected void generateLightBrightnessTable() { + float modifier = 0.0F; + + for (int steps = 0; steps <= 15; ++steps) { + float var3 = 1.0F - steps / 15.0F; + this.lightBrightnessTable[steps] = ((0.0F + var3) / (var3 * 3.0F + 1.0F) * (1.0F - modifier) + modifier)*3; + // System.out.println( this.lightBrightnessTable[steps]+"light"); + } + } + + @Override + public BlockPos getSpawnPoint() { + return this.getRandomizedSpawnPoint(); + } + + @Override + public float calculateCelestialAngle(long par1, float par3) { + return 0; + } + + @SideOnly(Side.CLIENT) + public int getMoonPhase(long par1, float par3) { + return 4; + } + + @SideOnly(Side.CLIENT) + @Override + public String getSaveFolder() { + return (getDimension() == 0 ? null : "dimdoors/limbo" + getDimension()); + } + + @Override + public boolean canCoordinateBeSpawn(int x, int z) { + BlockPos pos = this.world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)); + return world.getBlockState(pos).equals(mod_pocketDim.blockLimbo); + } + + @Override + public double getHorizon() { + return world.getHeight()/4-800; + } + + @SideOnly(Side.CLIENT) + @Override + public Vec3d getSkyColor(Entity cameraEntity, float partialTicks) + { + setCloudRenderer( new CloudRenderBlank()); + return Vec3d.ZERO; + + } + @SideOnly(Side.CLIENT) + @Override + public Vec3d getFogColor(float par1, float par2) { + return new Vec3d(.2, .2, .2); + } + + @Override + public int getRespawnDimension(EntityPlayerMP player) { + return 0; + } + + @Override + public IChunkGenerator createChunkGenerator() { + return new LimboGenerator(world, 45); + } + + @Override + public boolean canBlockFreeze(BlockPos pos, boolean byWater) { + return false; + } + + public static Location getLimboSkySpawn(EntityPlayer player, World world) { + int x = (int) (player.posX) + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); + int z = (int) (player.posZ) + MathHelper.clamp(player.world.rand.nextInt(), -100, 100); //-properties.LimboEntryRange, properties.LimboEntryRange); + return new Location(world, x, 700, z); + } + + @Override + public BlockPos getRandomizedSpawnPoint() { + int x = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); + int z = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); + return new BlockPos(x, 700, z); + } +} + + @Override + public DimensionType getDimensionType() { + return DimDoorDimensions.LIMBO; + } +} diff --git a/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java b/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java new file mode 100644 index 00000000..830a6c40 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java @@ -0,0 +1,7 @@ +package com.zixiken.dimdoors.world.personalpocket; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class WorldProviderPersonalPocket { +} diff --git a/src/main/java/com/zixiken/dimdoors/world/pocket/PocketSkyProvider.java b/src/main/java/com/zixiken/dimdoors/world/pocket/PocketSkyProvider.java new file mode 100644 index 00000000..19f080e9 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/pocket/PocketSkyProvider.java @@ -0,0 +1,20 @@ +package com.zixiken.dimdoors.world.pocket; + +import com.zixiken.dimdoors.world.CustomSkyProvider; +import net.minecraft.util.ResourceLocation; + +/** + * Created by Jared Johnson on 1/24/2017. + */ +public class PocketSkyProvider extends CustomSkyProvider +{ + @Override + public ResourceLocation getMoonRenderPath() { + return new ResourceLocation("DimDoors:textures/other/limboMoon.png"); + } + + @Override + public ResourceLocation getSunRenderPath() { + return new ResourceLocation("DimDoors:textures/other/limboSun.png"); + } +} diff --git a/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java new file mode 100644 index 00000000..af7899df --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java @@ -0,0 +1,12 @@ +package com.zixiken.dimdoors.world.pocket; + +import com.zixiken.dimdoors.world.DimDoorDimensions; +import net.minecraft.world.DimensionType; +import net.minecraft.world.WorldProvider; + +public class WorldProviderPocket extends WorldProvider { + @Override + public DimensionType getDimensionType() { + return DimDoorDimensions.POCKET; + } +} From e75d282b249a4cd9db52d6bf5bb9f36eb039c899 Mon Sep 17 00:00:00 2001 From: Waterpicker <Waterpickerenternity@gmail.com> Date: Thu, 26 Jan 2017 20:57:21 -0600 Subject: [PATCH 2/2] World draft 1 complete --- .../com/zixiken/dimdoors/DDProxyCommon.java | 4 + .../java/com/zixiken/dimdoors/DimDoors.java | 1 + .../com/zixiken/dimdoors/TeleportCommand.java | 59 +++++++++ .../zixiken/dimdoors/blocks/BlockLimbo.java | 32 +++++ .../zixiken/dimdoors/blocks/BlockRift.java | 5 +- .../zixiken/dimdoors/blocks/ModBlocks.java | 2 + .../dimdoors/shared/TeleportHelper.java | 4 - .../dimdoors/world/DimDoorDimensions.java | 16 ++- .../dimdoors/world/limbo/LimboBiome.java | 3 - .../dimdoors/world/limbo/LimboDecay.java | 23 ++-- .../dimdoors/world/limbo/LimboGenerator.java | 119 ++++++++++-------- .../world/limbo/WorldProviderLimbo.java | 9 +- .../WorldProviderPersonalPocket.java | 55 +++++++- .../world/{ => pocket}/PocketGenerator.java | 5 +- .../world/pocket/WorldProviderPocket.java | 87 ++++++++++++- .../pocket/WorldProviderPublicPocket.java | 16 +++ 16 files changed, 350 insertions(+), 90 deletions(-) create mode 100644 src/main/java/com/zixiken/dimdoors/TeleportCommand.java create mode 100644 src/main/java/com/zixiken/dimdoors/blocks/BlockLimbo.java rename src/main/java/com/zixiken/dimdoors/world/{ => pocket}/PocketGenerator.java (92%) create mode 100644 src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPublicPocket.java diff --git a/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java b/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java index 0c7cde86..e07eb114 100644 --- a/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java +++ b/src/main/java/com/zixiken/dimdoors/DDProxyCommon.java @@ -11,11 +11,15 @@ import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor; import com.zixiken.dimdoors.world.DimDoorDimensions; import net.minecraft.block.BlockDoor; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartedEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public abstract class DDProxyCommon implements IDDProxy { diff --git a/src/main/java/com/zixiken/dimdoors/DimDoors.java b/src/main/java/com/zixiken/dimdoors/DimDoors.java index e43c74ef..c2a7b97c 100644 --- a/src/main/java/com/zixiken/dimdoors/DimDoors.java +++ b/src/main/java/com/zixiken/dimdoors/DimDoors.java @@ -53,6 +53,7 @@ public class DimDoors { @Mod.EventHandler public void serverLoad(FMLServerStartingEvent event) { + event.registerServerCommand(new TeleportCommand()); //@todo event.registerServerCommand( new DDCommand() ); //to register commands that this mod offers? RiftRegistry.Instance.reset(); PocketSavedData.get(getDefWorld()); diff --git a/src/main/java/com/zixiken/dimdoors/TeleportCommand.java b/src/main/java/com/zixiken/dimdoors/TeleportCommand.java new file mode 100644 index 00000000..bfce7169 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/TeleportCommand.java @@ -0,0 +1,59 @@ +package com.zixiken.dimdoors; + +import com.zixiken.dimdoors.shared.Location; +import com.zixiken.dimdoors.shared.TeleportHelper; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.Teleporter; +import net.minecraft.world.World; +import scala.Int; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Jared Johnson on 1/26/2017. + */ +public class TeleportCommand extends CommandBase { + private final List aliases; + + public TeleportCommand() + { + aliases = new ArrayList(); + + aliases.add("dimteleport"); + + } + + @Override + public String getName() { + return "dimteleport"; + } + + @Override + public String getUsage(ICommandSender sender) { + return "dimteleport <dimension>"; + } + + @Override + public List<String> getAliases() { + return aliases; + } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + int id = Integer.parseInt(args[0]); + + if (sender instanceof EntityPlayerMP) { + server.getPlayerList().transferPlayerToDimension((EntityPlayerMP) sender, Integer.parseInt(args[0]), new TeleportHelper(new Location(id, 0,300,0))); + + } + } +} diff --git a/src/main/java/com/zixiken/dimdoors/blocks/BlockLimbo.java b/src/main/java/com/zixiken/dimdoors/blocks/BlockLimbo.java new file mode 100644 index 00000000..a567eb46 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/blocks/BlockLimbo.java @@ -0,0 +1,32 @@ +package com.zixiken.dimdoors.blocks; + +import com.zixiken.dimdoors.world.limbo.LimboDecay; +import com.zixiken.dimdoors.world.limbo.WorldProviderLimbo; +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.Random; + +public class BlockLimbo extends Block { + public static final String ID = "blockLimbo"; + + public BlockLimbo() { + super(Material.GROUND, MapColor.BLACK); + setUnlocalizedName(ID); + setRegistryName(ID); + + setTickRandomly(true); + } + + @Override + public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { + //Make sure this block is in Limbo + if (world.provider instanceof WorldProviderLimbo) { + LimboDecay.applySpreadDecay(world, pos); + } + } +} diff --git a/src/main/java/com/zixiken/dimdoors/blocks/BlockRift.java b/src/main/java/com/zixiken/dimdoors/blocks/BlockRift.java index 09e807a8..871bd9bf 100644 --- a/src/main/java/com/zixiken/dimdoors/blocks/BlockRift.java +++ b/src/main/java/com/zixiken/dimdoors/blocks/BlockRift.java @@ -147,15 +147,14 @@ public class BlockRift extends Block implements ITileEntityProvider { x + .5, y + .5, z + .5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D)); */ - if (tile.shouldClose) //renders an opposite color effect if it is being closed by the rift remover - { + if (tile.shouldClose) //renders an opposite color effect if it is being closed by the rift remover{ FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX( worldIn, x + .5, y + .5, z + .5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D)); - } } + public boolean tryPlacingRift(World world, BlockPos pos) { return world != null && !isBlockImmune(world, pos) && world.setBlockState(pos, getDefaultState()); //@todo This returns false, because this block does not have blockstates configured correctly. !isBlockImmune doesn't seem to be true either though... diff --git a/src/main/java/com/zixiken/dimdoors/blocks/ModBlocks.java b/src/main/java/com/zixiken/dimdoors/blocks/ModBlocks.java index f88cf0ac..4795f25e 100644 --- a/src/main/java/com/zixiken/dimdoors/blocks/ModBlocks.java +++ b/src/main/java/com/zixiken/dimdoors/blocks/ModBlocks.java @@ -15,6 +15,7 @@ public class ModBlocks { public static BlockTransTrapdoor blockDimHatch; public static BlockDimWall blockDimWall; public static BlockRift blockRift; + public static BlockLimbo blockLimbo; public static void registerBlocks() { GameRegistry.register(blockDoorQuartz = new BlockDoorQuartz()); @@ -28,5 +29,6 @@ public class ModBlocks { GameRegistry.register(blockDimWall = new BlockDimWall()); GameRegistry.register(blockDimDoorTransient = new BlockDimDoorTransient()); GameRegistry.register(blockRift = new BlockRift()); + GameRegistry.register(blockLimbo = new BlockLimbo()); } } diff --git a/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java b/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java index 47e63b58..c8cbd37e 100644 --- a/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java +++ b/src/main/java/com/zixiken/dimdoors/shared/TeleportHelper.java @@ -26,10 +26,6 @@ public class TeleportHelper extends Teleporter { entityIn.setPositionAndUpdate(pos.getX() + .5, pos.getY() + .05, pos.getZ() + .5); } - public IBlockState toBlockState(String id) { - String[] list = id.split("["); - } - public static boolean teleport(Entity entity, Location newLocation) { if (DimDoors.isClient()) { //DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP."); diff --git a/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java b/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java index 65bc4e78..0034db58 100644 --- a/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java +++ b/src/main/java/com/zixiken/dimdoors/world/DimDoorDimensions.java @@ -1,20 +1,28 @@ package com.zixiken.dimdoors.world; import com.zixiken.dimdoors.world.limbo.WorldProviderLimbo; +import com.zixiken.dimdoors.world.personalpocket.WorldProviderPersonalPocket; import com.zixiken.dimdoors.world.pocket.WorldProviderPocket; +import com.zixiken.dimdoors.world.pocket.WorldProviderPublicPocket; import net.minecraft.world.DimensionType; import net.minecraftforge.common.DimensionManager; public class DimDoorDimensions { public static DimensionType LIMBO; - public static DimensionType POCKET; + public static DimensionType DUNGEON; + public static DimensionType PRIVATE; + public static DimensionType PUBLIC; public static void init() { - LIMBO = DimensionType.register("Limbo", "_limbo", DimensionManager.getNextFreeDimId(), WorldProviderPocket.class, false); - POCKET = DimensionType.register("Pocket", "_pocket", DimensionManager.getNextFreeDimId(), WorldProviderLimbo.class, false); + LIMBO = DimensionType.register("Limbo", "_limbo", 2, WorldProviderLimbo.class, false); + PRIVATE = DimensionType.register("Private", "_private", 3, WorldProviderPersonalPocket.class, false); //TODO: Figure out how to consiently get proper dimension ids + DUNGEON = DimensionType.register("Dungeon", "_dungeon", 4, WorldProviderPocket.class, false); + PUBLIC = DimensionType.register("Public", "_public", 5, WorldProviderPublicPocket.class, false); registerDimension(LIMBO); - registerDimension(POCKET); + registerDimension(PRIVATE); + registerDimension(DUNGEON); + registerDimension(PUBLIC); } public static void registerDimension(DimensionType dimension) { diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java index cddb0ebc..5a165704 100644 --- a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboBiome.java @@ -2,9 +2,6 @@ package com.zixiken.dimdoors.world.limbo; import com.zixiken.dimdoors.world.biomes.DimDoorsBiome; -/** - * Created by Jared Johnson on 1/24/2017. - */ public class LimboBiome extends DimDoorsBiome { public LimboBiome() { super("limbo"); diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java index cfb5bb37..e47482e6 100644 --- a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboDecay.java @@ -34,7 +34,7 @@ public class LimboDecay { public static IBlockState[] getDecaySequence() { if (decaySequence == null) { decaySequence = new IBlockState[] { - mod_pocketDim.blockLimbo, + ModBlocks.blockLimbo.getDefaultState(), Blocks.GRAVEL.getDefaultState(), Blocks.COBBLESTONE.getDefaultState(), Blocks.STONE.getDefaultState() @@ -47,16 +47,16 @@ public class LimboDecay { public static IBlockState[] getBlocksImmuneToDecay() { if (blocksImmuneToDecay == null) { blocksImmuneToDecay = new IBlockState[] { - mod_pocketDim.blockLimbo, + ModBlocks.blockLimbo.getDefaultState(), ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ANCIENT), ModBlocks.blockDimDoorTransient.getDefaultState(), ModBlocks.blockDimDoor.getDefaultState(), ModBlocks.blockDimDoorWarp.getDefaultState(), ModBlocks.blockRift.getDefaultState(), ModBlocks.blockDimDoorChaos.getDefaultState(), - ModBlocks.blockDoorGold, - ModBlocks.blockDoorQuartz, - ModBlocks.blockDimDoorGold + ModBlocks.blockDoorGold.getDefaultState(), + ModBlocks.blockDoorQuartz.getDefaultState(), + ModBlocks.blockDimDoorGold.getDefaultState() }; } @@ -67,8 +67,7 @@ public class LimboDecay { * Checks the blocks orthogonally around a given location (presumably the location of an Unraveled Fabric block) * and applies Limbo decay to them. This gives the impression that decay spreads outward from Unraveled Fabric. */ - public void applySpreadDecay(World world, BlockPos pos) - { + public static void applySpreadDecay(World world, BlockPos pos) { //Check if we randomly apply decay spread or not. This can be used to moderate the frequency of //full spread decay checks, which can also shift its performance impact on the game. if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE) { @@ -87,7 +86,7 @@ public class LimboDecay { * Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric. * This decay method is designed to stop players from avoiding Limbo decay by building floating structures. */ - public void applyRandomFastDecay() + public static void applyRandomFastDecay() { int x, y, z; int sectionY; @@ -118,10 +117,10 @@ public class LimboDecay { /** * Checks if a block can be decayed and, if so, changes it directly into Unraveled Fabric. */ - private boolean decayBlockFast(World world, BlockPos pos) { + private static boolean decayBlockFast(World world, BlockPos pos) { IBlockState block = world.getBlockState(pos); if (canDecayBlock(block, world, pos)) { - world.setBlockState(pos, mod_pocketDim.blockLimbo); + world.setBlockState(pos, ModBlocks.blockLimbo.getDefaultState()); return true; } return false; @@ -130,7 +129,7 @@ public class LimboDecay { /** * Checks if a block can be decayed and, if so, changes it to the next block ID along the decay sequence. */ - private boolean decayBlock(World world, BlockPos pos) { + private static boolean decayBlock(World world, BlockPos pos) { int index; IBlockState block = world.getBlockState(pos); if (canDecayBlock(block, world, pos)) { @@ -157,7 +156,7 @@ public class LimboDecay { /** * Checks if a block can decay. We will not decay air, certain DD blocks, or containers. */ - private boolean canDecayBlock(IBlockState block, World world, BlockPos pos) { + private static boolean canDecayBlock(IBlockState block, World world, BlockPos pos) { if (world.isAirBlock(pos )) { return false; } diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java index fb6d845d..193fcaf9 100644 --- a/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/LimboGenerator.java @@ -1,7 +1,10 @@ package com.zixiken.dimdoors.world.limbo; +import com.zixiken.dimdoors.blocks.BlockDimWall; +import com.zixiken.dimdoors.blocks.ModBlocks; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Biomes; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; @@ -14,6 +17,7 @@ import net.minecraft.world.gen.structure.MapGenScatteredFeature; import net.minecraftforge.common.BiomeManager; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -51,7 +55,7 @@ public class LimboGenerator implements IChunkGenerator private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); /** The biomes that are used to generate the chunk */ - private Biome[] biomesForGeneration = new Biome[1]; + private Biome[] biomesForGeneration = { new LimboBiome() }; /** A double array that hold terrain noise from noiseGen3 */ double[] noise3; @@ -78,9 +82,8 @@ public class LimboGenerator implements IChunkGenerator } //private CustomLimboPopulator spawner; - public LimboGenerator(World world, long seed, /*CustomLimboPopulator spawner*/) { + public LimboGenerator(World world, long seed /*CustomLimboPopulator spawner*/) { this.worldObj = world; - BiomeManager LimboGenerator.rand = new Random(seed); this.noiseGen1 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //base terrain this.noiseGen2 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //hillyness @@ -102,7 +105,7 @@ public class LimboGenerator implements IChunkGenerator this.worldObj = world; - this.spawner = spawner; + //this.spawner = spawner; } @Override @@ -111,7 +114,7 @@ public class LimboGenerator implements IChunkGenerator //TODO: Wtf? Why do you reinitialize the seed when we already initialized it in the constructor?! ~SenseiKiwi LimboGenerator.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L); ChunkPrimer primer = new ChunkPrimer(); - this.setBlocksInChunk(chunkX, chunkZ, primer); + this.scale(chunkX, chunkZ, primer); Chunk chunk = new Chunk(this.worldObj, primer, chunkX, chunkZ); chunk.generateSkylightMap(); @@ -255,62 +258,70 @@ public class LimboGenerator implements IChunkGenerator return par1ArrayOfDouble; } - public void setBlocksInChunk(int x, int z, ChunkPrimer blocks) { - byte var4 = 4; - byte var5 = 16; - byte var6 = 19; - int var7 = var4 + 1; - byte var8 = 17; - int var9 = var4 + 1; - this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, var7 + 5, var9 + 5); - this.noiseArray = this.initializeNoiseField(this.noiseArray, x * var4, 0, z * var4, var7, var8, var9); + public void scale(int x, int z, ChunkPrimer primer) { //Coursty of + // TODO: this: + this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); + this.noiseArray = this.initializeNoiseField(this.noiseArray, x * 4, 0, z * 4, 5, 17, 5); - for (int var10 = 0; var10 < var4; ++var10) { - for (int var11 = 0; var11 < var4; ++var11) { - for (int var12 = 0; var12 < var5; ++var12) { - double var13 = 0.125D; - double var15 = this.noiseArray[((((var10) * var9) + var11) * var8) + var12]; - double var17 = this.noiseArray[((var10) * var9 + var11 + 1) * var8 + var12]; - double var19 = this.noiseArray[((var10 + 1) * var9 + var11) * var8 + var12]; - double var21 = this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12]; - double var23 = (this.noiseArray[((var10) * var9 + var11) * var8 + var12 + 1] - var15) * var13; - double var25 = (this.noiseArray[((var10) * var9 + var11 + 1) * var8 + var12 + 1] - var17) * var13; - double var27 = (this.noiseArray[((var10 + 1) * var9 + var11) * var8 + var12 + 1] - var19) * var13; - double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13; + int xzSections = 4; + int xzSectionSize = 4; + int ySections = 16; + int ySectionSize = 8; - for (int var31 = 0; var31 < 8; ++var31) { - double var32 = 0.25D; - double var34 = var15; - double var36 = var17; - double var38 = (var19 - var15) * var32; - double var40 = (var21 - var17) * var32; + double xzScale = 1.0 / xzSectionSize; + double yScale = 1.0 / ySectionSize; + for (int sectionX = 0; sectionX < xzSections; ++sectionX) { + int xSectionPart = sectionX * xzSectionSize; + int i0__ = sectionX * (xzSections + 1); + int i1__ = (sectionX + 1) * (xzSections + 1); - for (int var42 = 0; var42 < 4; ++var42) { - int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31; - short var44 = 128; - var43 -= var44; - double var45 = 0.25D; - double var49 = (var36 - var34) * var45; - double var47 = var34 - var49; + for (int sectionZ = 0; sectionZ < xzSections; ++sectionZ) { + int zSectionPart = sectionZ * xzSectionSize; + int i0_0 = (i0__ + sectionZ) * (ySections + 1); + int i0_1 = (i0__ + sectionZ + 1) * (ySections + 1); + int i1_0 = (i1__ + sectionZ) * (ySections + 1); + int i1_1 = (i1__ + sectionZ + 1) * (ySections + 1); - for (int var51 = 0; var51 < 4; ++var51) { - if ((var47 += var49) > 0.0D) { - blocks[var43 += var44] = mod_pocketDim.blockLimbo; - } else if (var12 * 8 + var31 < var6) { - blocks[var43 += var44] = mod_pocketDim.blockDimWallPerm; - } else { - blocks[var43 += var44] = Blocks.air; + for (int sectionY = 0; sectionY < ySections; ++sectionY) { + int ySectionPart = sectionY * ySectionSize; + double v0y0 = this.noiseArray[i0_0 + sectionY]; + double v0y1 = this.noiseArray[i0_1 + sectionY]; + double v1y0 = this.noiseArray[i1_0 + sectionY]; + double v1y1 = this.noiseArray[i1_1 + sectionY]; + double d0y0 = (this.noiseArray[i0_0 + sectionY + 1] - v0y0) * yScale; + double d0y1 = (this.noiseArray[i0_1 + sectionY + 1] - v0y1) * yScale; + double d1y0 = (this.noiseArray[i1_0 + sectionY + 1] - v1y0) * yScale; + double d1y1 = (this.noiseArray[i1_1 + sectionY + 1] - v1y1) * yScale; + + for (int yRel = 0; yRel < ySectionSize; ++yRel) { + int yCoord = ySectionPart + yRel; + double vxy0 = v0y0; + double vxy1 = v0y1; + double dxy0 = (v1y0 - v0y0) * xzScale; + double dxy1 = (v1y1 - v0y1) * xzScale; + + for (int xRel = 0; xRel < xzSectionSize; ++xRel) { + int xCoord = xSectionPart + xRel; + double dxyz = (vxy1 - vxy0) * xzScale; + double vxyz = vxy0 - dxyz; + + for (int zRel = 0; zRel < xzSectionSize; ++zRel) { + int zCoord = zSectionPart + zRel; + if(vxyz > 0) { + primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.blockLimbo.getDefaultState()); + } else if(yCoord < 6) { + primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ANCIENT)); } } - var34 += var38; - var36 += var40; + vxy0 += dxy0; + vxy1 += dxy1; } - var15 += var23; - var17 += var25; - var19 += var27; - var21 += var29; + v0y0 += d0y0; + v0y1 += d0y1; + v1y0 += d1y0; + v1y1 += d1y1; } } } @@ -319,9 +330,7 @@ public class LimboGenerator implements IChunkGenerator @Override public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType par1EnumCreatureType, BlockPos pos) { - - Biome biomegenbase = this.worldObj.getBiomeForCoordsBody(pos); - return biomegenbase == Biomes.SWAMPLAND && par1EnumCreatureType == EnumCreatureType.MONSTER && this.scatteredFeatureGenerator.isInsideStructure(pos) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType); + return new ArrayList<Biome.SpawnListEntry>(); } @Nullable diff --git a/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java b/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java index 99faf435..8e8d59dc 100644 --- a/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java +++ b/src/main/java/com/zixiken/dimdoors/world/limbo/WorldProviderLimbo.java @@ -1,5 +1,6 @@ package com.zixiken.dimdoors.world.limbo; +import com.zixiken.dimdoors.blocks.ModBlocks; import com.zixiken.dimdoors.client.CloudRenderBlank; import com.zixiken.dimdoors.shared.Location; import com.zixiken.dimdoors.world.DimDoorDimensions; @@ -20,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class WorldProviderLimbo extends WorldProvider { private IRenderHandler skyRenderer; - private CustomLimboPopulator spawner; + //private CustomLimboPopulator spawner; public WorldProviderLimbo() { this.hasNoSky = false; @@ -82,16 +83,15 @@ public class WorldProviderLimbo extends WorldProvider { return 4; } - @SideOnly(Side.CLIENT) @Override public String getSaveFolder() { - return (getDimension() == 0 ? null : "dimdoors/limbo" + getDimension()); + return (getDimension() == 0 ? null : "limbo" + getDimension()); } @Override public boolean canCoordinateBeSpawn(int x, int z) { BlockPos pos = this.world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)); - return world.getBlockState(pos).equals(mod_pocketDim.blockLimbo); + return world.getBlockState(pos).equals(ModBlocks.blockLimbo.getDefaultState()); } @Override @@ -140,7 +140,6 @@ public class WorldProviderLimbo extends WorldProvider { int z = MathHelper.clamp(this.world.rand.nextInt(), -500, 500); return new BlockPos(x, 700, z); } -} @Override public DimensionType getDimensionType() { diff --git a/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java b/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java index 830a6c40..c9d4a1e8 100644 --- a/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java +++ b/src/main/java/com/zixiken/dimdoors/world/personalpocket/WorldProviderPersonalPocket.java @@ -1,7 +1,60 @@ package com.zixiken.dimdoors.world.personalpocket; +import com.zixiken.dimdoors.client.CloudRenderBlank; +import com.zixiken.dimdoors.world.DimDoorDimensions; +import com.zixiken.dimdoors.world.pocket.WorldProviderPocket; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.DimensionType; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + /** * Created by Jared Johnson on 1/24/2017. */ -public class WorldProviderPersonalPocket { +public class WorldProviderPersonalPocket extends WorldProviderPocket { + @SideOnly(Side.CLIENT) + @Override + public Vec3d getSkyColor(Entity cameraEntity, float partialTicks) + { + setCloudRenderer(new CloudRenderBlank()); + return new Vec3d(1,1,1); + } + + public boolean isSurfaceWorld() { + return false; + } + + @Override + protected void generateLightBrightnessTable() { + for (int i = 0; i <= 15; ++i) { + this.lightBrightnessTable[i] = (15); + } + } + + @Override + public double getHorizon() { + return world.getHeight()-256; + } + + @SideOnly(Side.CLIENT) + @Override + public Vec3d getFogColor(float par1, float par2) { + return new Vec3d(1,1,1); + } + + @Override + public int getActualHeight() { + return -256; + } + + @Override + public String getSaveFolder() { + return (getDimension() == 0 ? null : "personal"); + } + + @Override + public DimensionType getDimensionType() { + return DimDoorDimensions.PRIVATE; + } } diff --git a/src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java b/src/main/java/com/zixiken/dimdoors/world/pocket/PocketGenerator.java similarity index 92% rename from src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java rename to src/main/java/com/zixiken/dimdoors/world/pocket/PocketGenerator.java index afc5ef50..952a6795 100644 --- a/src/main/java/com/zixiken/dimdoors/world/PocketGenerator.java +++ b/src/main/java/com/zixiken/dimdoors/world/pocket/PocketGenerator.java @@ -1,4 +1,4 @@ -package com.zixiken.dimdoors.world; +package com.zixiken.dimdoors.world.pocket; import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.math.BlockPos; @@ -9,6 +9,7 @@ import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.IChunkGenerator; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.List; public class PocketGenerator implements IChunkGenerator { @@ -46,7 +47,7 @@ public class PocketGenerator implements IChunkGenerator { @Override public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { - return null; + return new ArrayList<Biome.SpawnListEntry>(); } @Nullable diff --git a/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java index af7899df..124b44b1 100644 --- a/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java +++ b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPocket.java @@ -1,12 +1,97 @@ package com.zixiken.dimdoors.world.pocket; +import com.zixiken.dimdoors.client.CloudRenderBlank; import com.zixiken.dimdoors.world.DimDoorDimensions; +import net.minecraft.client.renderer.Vector3d; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.DimensionType; import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class WorldProviderPocket extends WorldProvider { + //protected CustomLimboPopulator spawner; + protected IRenderHandler skyRenderer; + + public WorldProviderPocket() { + this.hasNoSky = true; + } + + + @Override + public String getSaveFolder() { + return (getDimension() == 0 ? null : "private"); + } + + @SideOnly(Side.CLIENT) + @Override + public Vec3d getSkyColor(Entity cameraEntity, float partialTicks) { + setCloudRenderer( new CloudRenderBlank()); + return Vec3d.ZERO; + } + + @SideOnly(Side.CLIENT) + @Override + public Vec3d getFogColor(float par1, float par2) { + return Vec3d.ZERO; + } + + @Override + public double getHorizon() { + return world.getHeight(); + } + + @Override + public IChunkGenerator createChunkGenerator() { + return new PocketGenerator(world, 0); //, spawner); + } + + @Override + public boolean canSnowAt(BlockPos pos, boolean light) { + return false; + } + + @Override + public boolean canBlockFreeze(BlockPos pos, boolean byWater) { + return false; + } + + public float calculateCelestialAngle(long par1, float par3) { + return .5F; + } + + @Override + protected void generateLightBrightnessTable() { + for (int steps = 0; steps <= 15; ++steps) { + float var3 = (float) (Math.pow(steps,1.5) / Math.pow(15.0F,1.5)); + this.lightBrightnessTable[15-steps] = var3; + System.out.println( this.lightBrightnessTable[steps]+"light"); + } + } + + @Override + public int getRespawnDimension(EntityPlayerMP player) { + return getDimension(); + } + + @Override + public boolean canRespawnHere() { + return false; + } + + @Override + public int getActualHeight() { + return 256; + } + @Override public DimensionType getDimensionType() { - return DimDoorDimensions.POCKET; + return DimDoorDimensions.DUNGEON; } } diff --git a/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPublicPocket.java b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPublicPocket.java new file mode 100644 index 00000000..2507ccb6 --- /dev/null +++ b/src/main/java/com/zixiken/dimdoors/world/pocket/WorldProviderPublicPocket.java @@ -0,0 +1,16 @@ +package com.zixiken.dimdoors.world.pocket; + +import com.zixiken.dimdoors.world.DimDoorDimensions; +import net.minecraft.world.DimensionType; + +public class WorldProviderPublicPocket extends WorldProviderPocket { + @Override + public String getSaveFolder() { + return (getDimension() == 0 ? null : "public"); + } + + @Override + public DimensionType getDimensionType() { + return DimDoorDimensions.PUBLIC; + } +}