diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2017-04-30 21:40:30 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2017-04-30 21:40:30 +1000 |
commit | 0ce12b7874ff31d6fabc6c6f7402e00f7b0f34c1 (patch) | |
tree | 04bd6b3b661e0e91e85d65fd89b79c54684b06a6 /src/Java/gtPlusPlus/core/world | |
parent | 13155dc73e27b92fb0f091e0fb133b07a35248eb (diff) | |
download | GT5-Unofficial-0ce12b7874ff31d6fabc6c6f7402e00f7b0f34c1.tar.gz GT5-Unofficial-0ce12b7874ff31d6fabc6c6f7402e00f7b0f34c1.tar.bz2 GT5-Unofficial-0ce12b7874ff31d6fabc6c6f7402e00f7b0f34c1.zip |
+ Added the base work for a new dimension.
Diffstat (limited to 'src/Java/gtPlusPlus/core/world')
29 files changed, 4548 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/world/DimensionIDs.java b/src/Java/gtPlusPlus/core/world/DimensionIDs.java new file mode 100644 index 0000000000..52ed10ccef --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/DimensionIDs.java @@ -0,0 +1,7 @@ +package gtPlusPlus.core.world; + +public class DimensionIDs { + + public static final int Dimension_A = 210; + +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModBush.java b/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModBush.java new file mode 100644 index 0000000000..6b467322c8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModBush.java @@ -0,0 +1,156 @@ +package gtPlusPlus.core.world.dimensionA.block; + +import static net.minecraftforge.common.EnumPlantType.*; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockModBush extends Block implements IPlantable { + protected BlockModBush(Material p_i45395_1_) + { + super(p_i45395_1_); + this.setTickRandomly(true); + float f = 0.2F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f); + this.setCreativeTab(CreativeTabs.tabDecorations); + GameRegistry.registerBlock(this, "modBush"); + } + + protected BlockModBush() + { + this(Material.plants); + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z + */ + @Override + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + /** + * is the block grass, dirt or farmland + */ + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.grass || p_149854_1_ == Blocks.dirt; + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + this.checkAndDropBlock(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + + /** + * checks if the block can stay, if not drop as item + */ + protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_) + { + if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_)) + { + this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_), 0); + p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, getBlockById(0), 0, 2); + } + } + + /** + * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants. + */ + @Override + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been + * cleared to be reused) + */ + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + @Override + public boolean isOpaqueCube() + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return 1; + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + if (this == Blocks.wheat) return Crop; + if (this == Blocks.carrots) return Crop; + if (this == Blocks.potatoes) return Crop; + if (this == Blocks.melon_stem) return Crop; + if (this == Blocks.pumpkin_stem) return Crop; + if (this == Blocks.waterlily) return Water; + if (this == Blocks.nether_wart) return Nether; + if (this == Blocks.sapling) return Plains; + return Plains; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return this; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModPortal.java b/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModPortal.java new file mode 100644 index 0000000000..5fa45a5b41 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModPortal.java @@ -0,0 +1,455 @@ +package gtPlusPlus.core.world.dimensionA.block; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.world.DimensionIDs; +import gtPlusPlus.core.world.dimensionA.util.Dimension_A_Teleporter; +import net.minecraft.block.Block; +import net.minecraft.block.BlockBreakable; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.util.*; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockModPortal extends BlockBreakable +{ + public static final int[][] field_150001_a = new int[][] {new int[0], {3, 1}, {2, 0}}; + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000284"; + + public BlockModPortal(String name) + { + super("portal", Material.portal, false); + this.setTickRandomly(true); + this.setBlockName(name); + this.setBlockTextureName("tutorial:" + name); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(World world, int x, int y, int z, Random random) { + super.updateTick(world, x, y, z, random); + if (world.provider.isSurfaceWorld() && world.getGameRules().getGameRuleBooleanValue("doMobSpawning") && random.nextInt(2000) < world.difficultySetting.getDifficultyId()) { + int l; + for (l = y; !World.doesBlockHaveSolidTopSurface(world, x, l, z) && l > 0; --l) { + ; + } + if (l > 0 && !world.getBlock(x, l + 1, z).isNormalCube()) { + Entity entity = ItemMonsterPlacer.spawnCreature(world, 57, x + 0.5D, l + 1.1D, z + 0.5D); + if (entity != null) { + entity.timeUntilPortal = entity.getPortalCooldown(); + } + } + } + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been + * cleared to be reused) + */ + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + return null; + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockaccess, int x, int y, int z) { + int l = func_149999_b(blockaccess.getBlockMetadata(x, y, z)); + if (l == 0) { + if (blockaccess.getBlock(x - 1, y, z) != this && blockaccess.getBlock(x + 1, y, z) != this) { + l = 2; + } else { + l = 1; + } + if (blockaccess instanceof World && !((World)blockaccess).isRemote) { + ((World)blockaccess).setBlockMetadataWithNotify(x, y, z, l, 2); + } + } + float f = 0.125F; + float f1 = 0.125F; + if (l == 1) { + f = 0.5F; + } + if (l == 2) { + f1 = 0.5F; + } + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock(){ + return false; + } + + public boolean getPortalSize(World world, int x, int y, int z) { + BlockModPortal.Size size = new BlockModPortal.Size(world, x, y, z, 1); + BlockModPortal.Size size1 = new BlockModPortal.Size(world, x, y, z, 2); + if (size.func_150860_b() && size.field_150864_e == 0) { + size.func_150859_c(); + return true; + } + else if (size1.func_150860_b() && size1.field_150864_e == 0) { + size1.func_150859_c(); + return true; + } else { + return false; + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block){ + int l = func_149999_b(world.getBlockMetadata(x, y, z)); + BlockModPortal.Size size = new BlockModPortal.Size(world, x, y, z, 1); + BlockModPortal.Size size1 = new BlockModPortal.Size(world, x, y, z, 2); + if (l == 1 && (!size.func_150860_b() || size.field_150864_e < size.field_150868_h * size.field_150862_g)) + { + world.setBlock(x, y, z, Blocks.air); + } + else if (l == 2 && (!size1.func_150860_b() || size1.field_150864_e < size1.field_150868_h * size1.field_150862_g)) + { + world.setBlock(x, y, z, Blocks.air); + } + else if (l == 0 && !size.func_150860_b() && !size1.func_150860_b()) + { + world.setBlock(x, y, z, Blocks.air); + } + } + + /** + * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given + * coordinates. Args: blockAccess, x, y, z, side + */ + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + int i1 = 0; + + if (p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_) == this) + { + i1 = func_149999_b(p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_)); + + if (i1 == 0) + { + return false; + } + + if (i1 == 2 && p_149646_5_ != 5 && p_149646_5_ != 4) + { + return false; + } + + if (i1 == 1 && p_149646_5_ != 3 && p_149646_5_ != 2) + { + return false; + } + } + + boolean flag = p_149646_1_.getBlock(p_149646_2_ - 1, p_149646_3_, p_149646_4_) == this && p_149646_1_.getBlock(p_149646_2_ - 2, p_149646_3_, p_149646_4_) != this; + boolean flag1 = p_149646_1_.getBlock(p_149646_2_ + 1, p_149646_3_, p_149646_4_) == this && p_149646_1_.getBlock(p_149646_2_ + 2, p_149646_3_, p_149646_4_) != this; + boolean flag2 = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ - 1) == this && p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ - 2) != this; + boolean flag3 = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ + 1) == this && p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ + 2) != this; + boolean flag4 = flag || flag1 || i1 == 1; + boolean flag5 = flag2 || flag3 || i1 == 2; + return flag4 && p_149646_5_ == 4 ? true : (flag4 && p_149646_5_ == 5 ? true : (flag5 && p_149646_5_ == 2 ? true : flag5 && p_149646_5_ == 3)); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if ((entity.ridingEntity == null) && (entity.riddenByEntity == null) && ((entity instanceof EntityPlayerMP))) { + EntityPlayerMP thePlayer = (EntityPlayerMP)entity; + if (thePlayer.timeUntilPortal > 0) { + thePlayer.timeUntilPortal = 10; + } else if (thePlayer.dimension != DimensionIDs.Dimension_A) { + thePlayer.timeUntilPortal = 10; + thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, DimensionIDs.Dimension_A, new Dimension_A_Teleporter(thePlayer.mcServer.worldServerForDimension(DimensionIDs.Dimension_A))); + } else { + thePlayer.timeUntilPortal = 10; + thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new Dimension_A_Teleporter(thePlayer.mcServer.worldServerForDimension(0))); + } + } + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random){ + if (random.nextInt(100) == 0) { + world.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "portal.portal", 0.5F, random.nextFloat() * 0.4F + 0.8F, false); + } + for (int l = 0; l < 4; ++l) { + double d0 = x + random.nextFloat(); + double d1 = y + random.nextFloat(); + double d2 = z + random.nextFloat(); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + int i1 = random.nextInt(2) * 2 - 1; + d3 = (random.nextFloat() - 0.5D) * 0.5D; + d4 = (random.nextFloat() - 0.5D) * 0.5D; + d5 = (random.nextFloat() - 0.5D) * 0.5D; + if (world.getBlock(x - 1, y, z) != this && world.getBlock(x + 1, y, z) != this) { + d0 = x + 0.5D + 0.25D * i1; + d3 = random.nextFloat() * 2.0F * i1; + } else { + d2 = z + 0.5D + 0.25D * i1; + d5 = random.nextFloat() * 2.0F * i1; + } + world.spawnParticle("portal", d0, d1, d2, d3, d4, d5); + } + } + + public static int func_149999_b(int p_149999_0_) + { + return p_149999_0_ & 3; + } + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return Item.getItemById(0); + } + + public static class Size + { + private final World worldObj; + private final int field_150865_b; + private final int field_150866_c; + private final int field_150863_d; + private int field_150864_e = 0; + private ChunkCoordinates field_150861_f; + private int field_150862_g; + private int field_150868_h; + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000285"; + + public Size(World p_i45415_1_, int p_i45415_2_, int p_i45415_3_, int p_i45415_4_, int p_i45415_5_) + { + this.worldObj = p_i45415_1_; + this.field_150865_b = p_i45415_5_; + this.field_150863_d = BlockModPortal.field_150001_a[p_i45415_5_][0]; + this.field_150866_c = BlockModPortal.field_150001_a[p_i45415_5_][1]; + + for (int i1 = p_i45415_3_; p_i45415_3_ > i1 - 21 && p_i45415_3_ > 0 && this.getBlockMaterial(p_i45415_1_.getBlock(p_i45415_2_, p_i45415_3_ - 1, p_i45415_4_)); --p_i45415_3_) + { + ; + } + + int j1 = this.func_150853_a(p_i45415_2_, p_i45415_3_, p_i45415_4_, this.field_150863_d) - 1; + + if (j1 >= 0) + { + this.field_150861_f = new ChunkCoordinates(p_i45415_2_ + j1 * Direction.offsetX[this.field_150863_d], p_i45415_3_, p_i45415_4_ + j1 * Direction.offsetZ[this.field_150863_d]); + this.field_150868_h = this.func_150853_a(this.field_150861_f.posX, this.field_150861_f.posY, this.field_150861_f.posZ, this.field_150866_c); + + if (this.field_150868_h < 2 || this.field_150868_h > 21) + { + this.field_150861_f = null; + this.field_150868_h = 0; + } + } + + if (this.field_150861_f != null) + { + this.field_150862_g = this.func_150858_a(); + } + } + + protected int func_150853_a(int x, int y, int z, int p_150853_4_) + { + int j1 = Direction.offsetX[p_150853_4_]; + int k1 = Direction.offsetZ[p_150853_4_]; + int i1; + Block block; + + for (i1 = 0; i1 < 22; ++i1) + { + block = this.worldObj.getBlock(x + j1 * i1, y, z + k1 * i1); + + if (!this.getBlockMaterial(block)) + { + break; + } + + Block block1 = this.worldObj.getBlock(x + j1 * i1, y - 1, z + k1 * i1); + + if (block1 != Blocks.stone) + { + break; + } + } + + block = this.worldObj.getBlock(x + j1 * i1, y, z + k1 * i1); + return block == Blocks.stone ? i1 : 0; + } + + protected int func_150858_a() + { + int i; + int j; + int k; + int l; + label56: + + for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g) + { + i = this.field_150861_f.posY + this.field_150862_g; + + for (j = 0; j < this.field_150868_h; ++j) + { + k = this.field_150861_f.posX + j * Direction.offsetX[BlockModPortal.field_150001_a[this.field_150865_b][1]]; + l = this.field_150861_f.posZ + j * Direction.offsetZ[BlockModPortal.field_150001_a[this.field_150865_b][1]]; + Block block = this.worldObj.getBlock(k, i, l); + + if (!this.getBlockMaterial(block)) + { + break label56; + } + + if (block == ModBlocks.lightPortal) + { + ++this.field_150864_e; + } + + if (j == 0) + { + block = this.worldObj.getBlock(k + Direction.offsetX[BlockModPortal.field_150001_a[this.field_150865_b][0]], i, l + Direction.offsetZ[BlockModPortal.field_150001_a[this.field_150865_b][0]]); + + if (block != Blocks.stone) + { + break label56; + } + } + else if (j == this.field_150868_h - 1) + { + block = this.worldObj.getBlock(k + Direction.offsetX[BlockModPortal.field_150001_a[this.field_150865_b][1]], i, l + Direction.offsetZ[BlockModPortal.field_150001_a[this.field_150865_b][1]]); + + if (block != Blocks.stone) + { + break label56; + } + } + } + } + + for (i = 0; i < this.field_150868_h; ++i) + { + j = this.field_150861_f.posX + i * Direction.offsetX[BlockModPortal.field_150001_a[this.field_150865_b][1]]; + k = this.field_150861_f.posY + this.field_150862_g; + l = this.field_150861_f.posZ + i * Direction.offsetZ[BlockModPortal.field_150001_a[this.field_150865_b][1]]; + + if (this.worldObj.getBlock(j, k, l) != Blocks.stone) + { + this.field_150862_g = 0; + break; + } + } + + if (this.field_150862_g <= 21 && this.field_150862_g >= 3) + { + return this.field_150862_g; + } + else + { + this.field_150861_f = null; + this.field_150868_h = 0; + this.field_150862_g = 0; + return 0; + } + } + + protected boolean getBlockMaterial(Block block){ + return block.getMaterial() == Material.air || block == ModBlocks.blockHellfire || block == ModBlocks.lightPortal; + } + + public boolean func_150860_b() + { + return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21; + } + + public void func_150859_c() + { + for (int i = 0; i < this.field_150868_h; ++i) + { + int j = this.field_150861_f.posX + Direction.offsetX[this.field_150866_c] * i; + int k = this.field_150861_f.posZ + Direction.offsetZ[this.field_150866_c] * i; + + for (int l = 0; l < this.field_150862_g; ++l) + { + int i1 = this.field_150861_f.posY + l; + this.worldObj.setBlock(j, i1, k, ModBlocks.lightPortal, this.field_150865_b, 2); + } + } + } + } + + int blockColour = Utils.rgbtoHexValue(200, 50, 50); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/particle/EntityTreeFX.java b/src/Java/gtPlusPlus/core/world/dimensionA/particle/EntityTreeFX.java new file mode 100644 index 0000000000..f9b471f0d4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/particle/EntityTreeFX.java @@ -0,0 +1,103 @@ +package gtPlusPlus.core.world.dimensionA.particle; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +public class EntityTreeFX extends EntityFX{ + + //TODO: add abailty to change particle color in constructor. + + private float portalParticleScale; + private double portalPosX; + private double portalPosY; + private double portalPosZ; + + @SuppressWarnings("unused") + private static final String __OBFID = "CL_000003921"; + + public EntityTreeFX(World world, double posX, double posY, double posZ, double motionPosX, double motionPosY, double motionPosZ) + { + + super(world, posX, posY, posZ, motionPosX, motionPosY, motionPosZ); + this.motionX = motionPosX; + this.motionY = motionPosY; + this.motionZ = motionPosZ; + this.portalPosX = this.posX = posX; + this.portalPosY = this.posY = posY; + this.portalPosZ = this.posZ = posZ; + this.portalParticleScale = this.particleScale = this.rand.nextFloat() * 0.2F + 0.5F; + this.particleRed = 0.0F; + this.particleGreen = 0.0F; + this.particleBlue = 1.0F; + this.particleMaxAge = (int)(Math.random() * 10.0D) + 40; + this.noClip = true; + this.setParticleTextureIndex((int)(Math.random() * 8.0D)); + } + + @Override + public void renderParticle(Tessellator tessellator, float posX, float posY, float posZ, float movePosX, float movePosY, float movePosZ) + { + float f6 = (this.particleAge + posX) / this.particleMaxAge; + f6 = 1.0F - f6; + f6 *= f6; + f6 = 1.0F - f6; + this.particleScale = this.portalParticleScale * f6; + super.renderParticle(tessellator, posX, posY, posZ, movePosX, movePosY, movePosZ); + } + + @Override + public int getBrightnessForRender(float amount) + { + int i = super.getBrightnessForRender(amount); + float f1 = (float)this.particleAge / (float)this.particleMaxAge; + f1 *= f1; + f1 *= f1; + int j = i & 255; + int k = i >> 16 & 255; + k += (int)(f1 * 15.0F * 16.0F); + + if (k > 240) + { + k = 240; + } + + return j | k << 16; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(float amount) + { + float f1 = super.getBrightness(amount); + float f2 = (float)this.particleAge / (float)this.particleMaxAge; + f2 = f2 * f2 * f2 * f2; + return f1 * (1.0F - f2) + f2; + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + float f = (float)this.particleAge / (float)this.particleMaxAge; + float f1 = f; + f = -f + f * f * 2.0F; + f = 1.0F - f; + this.posX = this.portalPosX + this.motionX * f; + this.posY = this.portalPosY + this.motionY * f + (1.0F - f1); + this.posZ = this.portalPosZ + this.motionZ * f; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/util/Dimension_A_Teleporter.java b/src/Java/gtPlusPlus/core/world/dimensionA/util/Dimension_A_Teleporter.java new file mode 100644 index 0000000000..d1159691d5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/util/Dimension_A_Teleporter.java @@ -0,0 +1,531 @@ +package gtPlusPlus.core.world.dimensionA.util; + +import java.util.*; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.xmod.gregtech.api.objects.XSTR; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.*; +import net.minecraft.world.*; + +public class Dimension_A_Teleporter extends Teleporter +{ + private final WorldServer worldServerInstance; + /** A private Random() function in Teleporter */ + private final XSTR random; + /** Stores successful portal placement locations for rapid lookup. */ + private final LongHashMap destinationCoordinateCache = new LongHashMap(); + /** + * A list of valid keys for the destinationCoordainteCache. These are based on the X & Z of the players initial + * location. + */ + @SuppressWarnings("rawtypes") + private final List destinationCoordinateKeys = new ArrayList(); + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000153"; + + public Dimension_A_Teleporter(WorldServer p_i1963_1_) + { + super(p_i1963_1_); + this.worldServerInstance = p_i1963_1_; + this.random = new XSTR(p_i1963_1_.getSeed()); + } + + /** + * Place an entity in a nearby portal, creating one if necessary. + */ + @Override + public void placeInPortal(Entity p_77185_1_, double p_77185_2_, double p_77185_4_, double p_77185_6_, float p_77185_8_) + { + if (this.worldServerInstance.provider.dimensionId != 1) + { + if (!this.placeInExistingPortal(p_77185_1_, p_77185_2_, p_77185_4_, p_77185_6_, p_77185_8_)) + { + this.makePortal(p_77185_1_); + this.placeInExistingPortal(p_77185_1_, p_77185_2_, p_77185_4_, p_77185_6_, p_77185_8_); + } + } + else + { + int i = MathHelper.floor_double(p_77185_1_.posX); + int j = MathHelper.floor_double(p_77185_1_.posY) - 1; + int k = MathHelper.floor_double(p_77185_1_.posZ); + byte b0 = 1; + byte b1 = 0; + + for (int l = -2; l <= 2; ++l) + { + for (int i1 = -2; i1 <= 2; ++i1) + { + for (int j1 = -1; j1 < 3; ++j1) + { + int k1 = i + i1 * b0 + l * b1; + int l1 = j + j1; + int i2 = k + i1 * b1 - l * b0; + boolean flag = j1 < 0; + this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.stone : Blocks.air); + } + } + } + + p_77185_1_.setLocationAndAngles(i, j, k, p_77185_1_.rotationYaw, 0.0F); + p_77185_1_.motionX = p_77185_1_.motionY = p_77185_1_.motionZ = 0.0D; + } + } + + /** + * Place an entity in a nearby portal which already exists. + */ + @Override + @SuppressWarnings("unchecked") + public boolean placeInExistingPortal(Entity p_77184_1_, double p_77184_2_, double p_77184_4_, double p_77184_6_, float p_77184_8_) + { + short short1 = 128; + double d3 = -1.0D; + int i = 0; + int j = 0; + int k = 0; + int l = MathHelper.floor_double(p_77184_1_.posX); + int i1 = MathHelper.floor_double(p_77184_1_.posZ); + long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); + boolean flag = true; + double d7; + int l3; + + if (this.destinationCoordinateCache.containsItem(j1)) + { + Dimension_A_Teleporter.PortalPosition portalposition = (Dimension_A_Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(j1); + d3 = 0.0D; + i = portalposition.posX; + j = portalposition.posY; + k = portalposition.posZ; + portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); + flag = false; + } + else + { + for (l3 = l - short1; l3 <= l + short1; ++l3) + { + double d4 = l3 + 0.5D - p_77184_1_.posX; + + for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) + { + double d5 = l1 + 0.5D - p_77184_1_.posZ; + + for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) + { + if (this.worldServerInstance.getBlock(l3, i2, l1) == ModBlocks.lightPortal) + { + while (this.worldServerInstance.getBlock(l3, i2 - 1, l1) == ModBlocks.lightPortal) + { + --i2; + } + + d7 = i2 + 0.5D - p_77184_1_.posY; + double d8 = d4 * d4 + d7 * d7 + d5 * d5; + + if (d3 < 0.0D || d8 < d3) + { + d3 = d8; + i = l3; + j = i2; + k = l1; + } + } + } + } + } + } + + if (d3 >= 0.0D) + { + if (flag) + { + this.destinationCoordinateCache.add(j1, new Dimension_A_Teleporter.PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); + this.destinationCoordinateKeys.add(Long.valueOf(j1)); + System.out.println("Location " + j1); + } + + double d11 = i + 0.5D; + double d6 = j + 0.5D; + d7 = k + 0.5D; + int i4 = -1; + + if (this.worldServerInstance.getBlock(i - 1, j, k) == ModBlocks.lightPortal) + { + i4 = 2; + } + + if (this.worldServerInstance.getBlock(i + 1, j, k) == ModBlocks.lightPortal) + { + i4 = 0; + } + + if (this.worldServerInstance.getBlock(i, j, k - 1) == ModBlocks.lightPortal) + { + i4 = 3; + } + + if (this.worldServerInstance.getBlock(i, j, k + 1) == ModBlocks.lightPortal) + { + i4 = 1; + } + + int j2 = p_77184_1_.getTeleportDirection(); + + if (i4 > -1) + { + int k2 = Direction.rotateLeft[i4]; + int l2 = Direction.offsetX[i4]; + int i3 = Direction.offsetZ[i4]; + int j3 = Direction.offsetX[k2]; + int k3 = Direction.offsetZ[k2]; + boolean flag1 = !this.worldServerInstance.isAirBlock(i + l2 + j3, j, k + i3 + k3) || !this.worldServerInstance.isAirBlock(i + l2 + j3, j + 1, k + i3 + k3); + boolean flag2 = !this.worldServerInstance.isAirBlock(i + l2, j, k + i3) || !this.worldServerInstance.isAirBlock(i + l2, j + 1, k + i3); + + if (flag1 && flag2) + { + i4 = Direction.rotateOpposite[i4]; + k2 = Direction.rotateOpposite[k2]; + l2 = Direction.offsetX[i4]; + i3 = Direction.offsetZ[i4]; + j3 = Direction.offsetX[k2]; + k3 = Direction.offsetZ[k2]; + l3 = i - j3; + d11 -= j3; + int k1 = k - k3; + d7 -= k3; + flag1 = !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j, k1 + i3 + k3) || !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j + 1, k1 + i3 + k3); + flag2 = !this.worldServerInstance.isAirBlock(l3 + l2, j, k1 + i3) || !this.worldServerInstance.isAirBlock(l3 + l2, j + 1, k1 + i3); + } + + float f1 = 0.5F; + float f2 = 0.5F; + + if (!flag1 && flag2) + { + f1 = 1.0F; + } + else if (flag1 && !flag2) + { + f1 = 0.0F; + } + else if (flag1 && flag2) + { + f2 = 0.0F; + } + + d11 += j3 * f1 + f2 * l2; + d7 += k3 * f1 + f2 * i3; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + + if (i4 == j2) + { + f3 = 1.0F; + f4 = 1.0F; + } + else if (i4 == Direction.rotateOpposite[j2]) + { + f3 = -1.0F; + f4 = -1.0F; + } + else if (i4 == Direction.rotateRight[j2]) + { + f5 = 1.0F; + f6 = -1.0F; + } + else + { + f5 = -1.0F; + f6 = 1.0F; + } + + double d9 = p_77184_1_.motionX; + double d10 = p_77184_1_.motionZ; + p_77184_1_.motionX = d9 * f3 + d10 * f6; + p_77184_1_.motionZ = d9 * f5 + d10 * f4; + p_77184_1_.rotationYaw = p_77184_8_ - j2 * 90 + i4 * 90; + } + else + { + p_77184_1_.motionX = p_77184_1_.motionY = p_77184_1_.motionZ = 0.0D; + } + + p_77184_1_.setLocationAndAngles(d11, d6, d7, p_77184_1_.rotationYaw, p_77184_1_.rotationPitch); + return true; + } + else + { + return false; + } + } + + @Override + public boolean makePortal(Entity p_85188_1_) + { + byte b0 = 16; + double d0 = -1.0D; + int i = MathHelper.floor_double(p_85188_1_.posX); + int j = MathHelper.floor_double(p_85188_1_.posY); + int k = MathHelper.floor_double(p_85188_1_.posZ); + int l = i; + int i1 = j; + int j1 = k; + int k1 = 0; + int l1 = this.random.nextInt(4); + int i2; + double d1; + int k2; + double d2; + int i3; + int j3; + int k3; + int l3; + int i4; + int j4; + int k4; + int l4; + int i5; + double d3; + double d4; + + for (i2 = i - b0; i2 <= i + b0; ++i2) + { + d1 = i2 + 0.5D - p_85188_1_.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) + { + d2 = k2 + 0.5D - p_85188_1_.posZ; + label274: + + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) + { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) + { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) + { + --i3; + } + + for (j3 = l1; j3 < l1 + 4; ++j3) + { + k3 = j3 % 2; + l3 = 1 - k3; + + if (j3 % 4 >= 2) + { + k3 = -k3; + l3 = -l3; + } + + for (i4 = 0; i4 < 3; ++i4) + { + for (j4 = 0; j4 < 4; ++j4) + { + for (k4 = -1; k4 < 4; ++k4) + { + l4 = i2 + (j4 - 1) * k3 + i4 * l3; + i5 = i3 + k4; + int j5 = k2 + (j4 - 1) * l3 - i4 * k3; + + if (k4 < 0 && !this.worldServerInstance.getBlock(l4, i5, j5).getMaterial().isSolid() || k4 >= 0 && !this.worldServerInstance.isAirBlock(l4, i5, j5)) + { + continue label274; + } + } + } + } + + d3 = i3 + 0.5D - p_85188_1_.posY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + + if (d0 < 0.0D || d4 < d0) + { + d0 = d4; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 4; + } + } + } + } + } + } + + if (d0 < 0.0D) + { + for (i2 = i - b0; i2 <= i + b0; ++i2) + { + d1 = i2 + 0.5D - p_85188_1_.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) + { + d2 = k2 + 0.5D - p_85188_1_.posZ; + label222: + + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) + { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) + { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) + { + --i3; + } + + for (j3 = l1; j3 < l1 + 2; ++j3) + { + k3 = j3 % 2; + l3 = 1 - k3; + + for (i4 = 0; i4 < 4; ++i4) + { + for (j4 = -1; j4 < 4; ++j4) + { + k4 = i2 + (i4 - 1) * k3; + l4 = i3 + j4; + i5 = k2 + (i4 - 1) * l3; + + if (j4 < 0 && !this.worldServerInstance.getBlock(k4, l4, i5).getMaterial().isSolid() || j4 >= 0 && !this.worldServerInstance.isAirBlock(k4, l4, i5)) + { + continue label222; + } + } + } + + d3 = i3 + 0.5D - p_85188_1_.posY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + + if (d0 < 0.0D || d4 < d0) + { + d0 = d4; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 2; + } + } + } + } + } + } + } + + int k5 = l; + int j2 = i1; + k2 = j1; + int l5 = k1 % 2; + int l2 = 1 - l5; + + if (k1 % 4 >= 2) + { + l5 = -l5; + l2 = -l2; + } + + boolean flag; + + if (d0 < 0.0D) + { + if (i1 < 70) + { + i1 = 70; + } + + if (i1 > this.worldServerInstance.getActualHeight() - 10) + { + i1 = this.worldServerInstance.getActualHeight() - 10; + } + + j2 = i1; + + for (i3 = -1; i3 <= 1; ++i3) + { + for (j3 = 1; j3 < 3; ++j3) + { + for (k3 = -1; k3 < 3; ++k3) + { + l3 = k5 + (j3 - 1) * l5 + i3 * l2; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2 - i3 * l5; + flag = k3 < 0; + this.worldServerInstance.setBlock(l3, i4, j4, flag ? Blocks.stone : Blocks.air); + } + } + } + } + + for (i3 = 0; i3 < 4; ++i3) + { + for (j3 = 0; j3 < 4; ++j3) + { + for (k3 = -1; k3 < 4; ++k3) + { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + flag = j3 == 0 || j3 == 3 || k3 == -1 || k3 == 3; + this.worldServerInstance.setBlock(l3, i4, j4, flag ? Blocks.stone : ModBlocks.lightPortal, 0, 2); + } + } + + for (j3 = 0; j3 < 4; ++j3) + { + for (k3 = -1; k3 < 4; ++k3) + { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + this.worldServerInstance.notifyBlocksOfNeighborChange(l3, i4, j4, this.worldServerInstance.getBlock(l3, i4, j4)); + } + } + } + + return true; + } + + /** + * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a + * WorldServer.getTotalWorldTime() value. + */ + @Override + public void removeStalePortalLocations(long p_85189_1_) + { + if (p_85189_1_ % 100L == 0L) + { + @SuppressWarnings("rawtypes") + Iterator iterator = this.destinationCoordinateKeys.iterator(); + long j = p_85189_1_ - 600L; + + while (iterator.hasNext()) + { + Long olong = (Long)iterator.next(); + Dimension_A_Teleporter.PortalPosition portalposition = (Dimension_A_Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue()); + + if (portalposition == null || portalposition.lastUpdateTime < j) + { + iterator.remove(); + this.destinationCoordinateCache.remove(olong.longValue()); + } + } + } + } + + public class PortalPosition extends ChunkCoordinates + { + /** The worldtime at which this PortalPosition was last verified */ + public long lastUpdateTime; + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000154"; + + public PortalPosition(int p_i1962_2_, int p_i1962_3_, int p_i1962_4_, long p_i1962_5_) + { + super(p_i1962_2_, p_i1962_3_, p_i1962_4_); + this.lastUpdateTime = p_i1962_5_; + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/util/Names.java b/src/Java/gtPlusPlus/core/world/dimensionA/util/Names.java new file mode 100644 index 0000000000..2ad0dc3adb --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/util/Names.java @@ -0,0 +1,10 @@ +package gtPlusPlus.core.world.dimensionA.util; + +/** + * Holds all names for biomes, blocks and items. + * @author Jimmy04Creeper + */ +public class Names { + + public static final String FORESTBIOMENAME = "Blue light Forest"; +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/util/ReadFile.java b/src/Java/gtPlusPlus/core/world/dimensionA/util/ReadFile.java new file mode 100644 index 0000000000..73bfdbf705 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/util/ReadFile.java @@ -0,0 +1,91 @@ +package gtPlusPlus.core.world.dimensionA.util; + +import java.io.*; + +public class ReadFile { + + private static int[] fileData; + + private static int numberOfLinesInFile; + + public static void findFileAndRead(String filePath){ + File file = new File(filePath); + if(file.exists() == true){ + System.out.println("file Found @ " + file.getAbsolutePath()); + try { + countLines(file); + } catch (IOException e) { + e.printStackTrace(); + } + readFileStrings(file); + }else{ + System.out.println("Can not find File"); + } + } + + /** + * Count the Nukber of Lnes in the file. + * @param file + * @return int numberOfLines + * @throws IOException + */ + private static int countLines(File file) throws IOException{ + FileReader reader = new FileReader(file); + BufferedReader buffedreader = new BufferedReader(reader); + @SuppressWarnings("unused") + String aLine; + numberOfLinesInFile = 0; + while((aLine = buffedreader.readLine()) != null){ + numberOfLinesInFile++; + } + buffedreader.close(); + return numberOfLinesInFile; + } + + /** + * Reads a File as Strings. + */ + public static void readFileStrings(File file){ + try { + FileReader reader = new FileReader(file); + BufferedReader buffedreader = new BufferedReader(reader); + String[] fileData = new String[numberOfLinesInFile]; + for(int i = 0; i < numberOfLinesInFile; i++){ + fileData[i] = buffedreader.readLine(); + System.out.println(fileData[i]); + } + reader.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Reads a File as ints. + */ + public static void readFileInts(File file){ + try { + FileReader reader = new FileReader(file); + BufferedReader buffedreader = new BufferedReader(reader); + + fileData = new int[numberOfLinesInFile]; + for(int i = 0; i < numberOfLinesInFile; i++){ + int inits = Integer.parseInt(buffedreader.readLine()); + fileData[i] = inits; + System.out.println(fileData[i]); + } + reader.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** Get ints from the file **/ + public static int[] getIntList(){ + return fileData; + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/ChunkProviderForest.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/ChunkProviderForest.java new file mode 100644 index 0000000000..2fcc8c69af --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/ChunkProviderForest.java @@ -0,0 +1,489 @@ +package gtPlusPlus.core.world.dimensionA.world; + +import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.*; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.*; + +import java.util.List; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.world.dimensionA.world.biomes.ModBiomes; +import gtPlusPlus.xmod.gregtech.api.objects.XSTR; +import gtPlusPlus.xmod.thermalfoundation.block.TF_Blocks; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.*; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.*; +import net.minecraft.world.gen.feature.WorldGenDungeons; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraft.world.gen.structure.MapGenScatteredFeature; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.*; + +public class ChunkProviderForest implements IChunkProvider { + + /** RNG. */ + private XSTR rand; + + /** A NoiseGeneratorOctaves used in generating terrain */ + private NoiseGeneratorOctaves noiseGen1; + private NoiseGeneratorOctaves noiseGen2; + private NoiseGeneratorOctaves noiseGen3; + private NoiseGeneratorPerlin noisePerl; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen5; + + /** A NoiseGeneratorOctaves used in generating terrain */ + public NoiseGeneratorOctaves noiseGen6; + public NoiseGeneratorOctaves mobSpawnerNoise; + + /** Reference to the World object. */ + private World worldObj; + + /** are map structures going to be generated (e.g. strongholds) */ + private final boolean mapFeaturesEnabled; + + private WorldType worldType; + private final double[] noiseArray; + private final float[] parabolicField; + private double[] stoneNoise = new double[256]; + private MapGenBase caveGenerator = new MapGenCaves(); + + private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + + /** Holds ravine generator */ + private MapGenBase ravineGenerator = new MapGenRavine(); + + /** The biomes that are used to generate the chunk */ + private BiomeGenBase[] biomesForGeneration; + + /** A double array that hold terrain noise */ + double[] noise3; + double[] noise1; + double[] noise2; + double[] noise5; + int[][] field_73219_j = new int[32][32]; + + { + caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); + scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); + ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); + } + + public ChunkProviderForest(World world, long seed, boolean mapFeaturesEnabled) + { + Utils.LOG_INFO("Loading Chunk Provider for dimension."); + this.worldObj = world; + this.mapFeaturesEnabled = false; + this.worldType = world.getWorldInfo().getTerrainType(); + this.rand = new XSTR(seed); + this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16); + this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16); + this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8); + this.noisePerl = new NoiseGeneratorPerlin(this.rand, 4); + this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); + this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); + this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); + this.noiseArray = new double[825]; + this.parabolicField = new float[25]; + for (int j = -2; j <= 2; ++j) { + for (int k = -2; k <= 2; ++k) { + float f = 10.0F / MathHelper.sqrt_float(j * j + k * k + 0.2F); + this.parabolicField[j + 2 + (k + 2) * 5] = f; + } + } + NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noisePerl, noiseGen5, noiseGen6, mobSpawnerNoise}; + noiseGens = TerrainGen.getModdedNoiseGenerators(world, this.rand, noiseGens); + this.noiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; + this.noiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; + this.noiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; + this.noisePerl = (NoiseGeneratorPerlin)noiseGens[3]; + this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; + this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; + this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; + } + + /** + * Generates the shape of the terrain for the chunk though its all stone + * though the water is frozen if the temperature is low enough + */ + // TODO: generateTerrain? + public void func_147424_a(int par1, int par2, Block[] blocks) { + + //DONT EDIT THS METHOD UNLES YOU KNOW WHAT UR DOING OR MAKE A COPY INCASE U MESS IT UP.... + //YOU HAVE BE WARNED !!!!! + + byte b0 = 63; + this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, 10, 10); + this.func_147423_a(par1 * 4, 0, par2 * 4); + for (int k = 0; k < 4; ++k) { + int l = k * 5; + int i1 = (k + 1) * 5; + for (int j1 = 0; j1 < 4; ++j1) { + int k1 = (l + j1) * 33; + int l1 = (l + j1 + 1) * 33; + int i2 = (i1 + j1) * 33; + int j2 = (i1 + j1 + 1) * 33; + for (int k2 = 0; k2 < 32; ++k2) { + double d0 = 0.125D; + double d1 = this.noiseArray[k1 + k2]; + double d2 = this.noiseArray[l1 + k2]; + double d3 = this.noiseArray[i2 + k2]; + double d4 = this.noiseArray[j2 + k2]; + double d5 = (this.noiseArray[k1 + k2 + 1] - d1) * d0; + double d6 = (this.noiseArray[l1 + k2 + 1] - d2) * d0; + double d7 = (this.noiseArray[i2 + k2 + 1] - d3) * d0; + double d8 = (this.noiseArray[j2 + k2 + 1] - d4) * d0; + for (int l2 = 0; l2 < 8; ++l2) { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + for (int i3 = 0; i3 < 4; ++i3) { + int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; + short short1 = 256; + j3 -= short1; + double d14 = 0.25D; + double d16 = (d11 - d10) * d14; + double d15 = d10 - d16; + for (int k3 = 0; k3 < 4; ++k3) { + if ((d15 += d16) > 0.0D) { + blocks[j3 += short1] = Blocks.stone;//these can be set to custom blocks + } else if (k2 * 8 + l2 < b0) { + blocks[j3 += short1] = Blocks.water;//these can be set to custom blocks + } else { + blocks[j3 += short1] = null;//this is the air block i think. + } + } + d10 += d12; + d11 += d13; + } + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void replaceBlocksForBiome(int par1, int par2, Block[] blocks, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase) { + //Utils.LOG_INFO("Replacing block for biome."); + @SuppressWarnings("deprecation") + ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, blocks, par3ArrayOfByte, par4ArrayOfBiomeGenBase); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return; + double d0 = 0.03125D; + this.stoneNoise = this.noisePerl.func_151599_a(this.stoneNoise, par1 * 16, par2 * 16, 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); + for (int k = 0; k < 16; ++k) { + for (int l = 0; l < 16; ++l) { + ModBiomes biomegenbase = (ModBiomes) par4ArrayOfBiomeGenBase[l + k * 16]; + biomegenbase.genTerrainBlocks(this.worldObj, this.rand, blocks, par3ArrayOfByte, par1 * 16 + k, par2 * 16 + l, this.stoneNoise[l + k * 16]); + } + } + } + + /** + * loads or generates the chunk at the chunk location specified + */ + @Override + public Chunk loadChunk(int par1, int par2) { + return this.provideChunk(par1, par2); + } + + /** + * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the + * specified chunk from the map seed and chunk seed + */ + @Override + public Chunk provideChunk(int par1, int par2) { + this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L); + Block[] ablock = new Block[65536]; + byte[] abyte = new byte[65536]; + this.func_147424_a(par1, par2, ablock); + this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); + this.replaceBlocksForBiome(par1, par2, ablock, abyte, this.biomesForGeneration); + this.caveGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.ravineGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + if (this.mapFeaturesEnabled) { + this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + } + Chunk chunk = new Chunk(this.worldObj, ablock, abyte, par1, par2); + byte[] abyte1 = chunk.getBiomeArray(); + for (int k = 0; k < abyte1.length; ++k){ + abyte1[k] = (byte)this.biomesForGeneration[k].biomeID; + } + chunk.generateSkylightMap(); + return chunk; + } + + /** + * generates a subset of the level's terrain data. Takes 7 arguments: the + * [empty] noise array, the position, and the size. + */ + // TODO: initializeNoiseField? + private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_) { + + //DONT EDIT THS METHOD UNLES YOU KNOW WHAT UR DOING OR MAKE A COPY INCASE U MESS IT UP.... + //YOU HAVE BE WARNED !!!!! + + this.noise5 = this.noiseGen6.generateNoiseOctaves(this.noise5, p_147423_1_, p_147423_3_, 5, 5, 200.0D, 200.0D, 0.5D); + this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); + this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + int l = 0; + int i1 = 0; + for (int j1 = 0; j1 < 5; ++j1) { + for (int k1 = 0; k1 < 5; ++k1) { + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + byte b0 = 2; + BiomeGenBase biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; + for (int l1 = -b0; l1 <= b0; ++l1) { + for (int i2 = -b0; i2 <= b0; ++i2) { + BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; + float f3 = biomegenbase1.rootHeight; + float f4 = biomegenbase1.heightVariation; + if (this.worldType == WorldType.AMPLIFIED && f3 > 0.0F) { + f3 = 1.0F + f3 * 2.0F; + f4 = 1.0F + f4 * 4.0F; + } + float f5 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); + if (biomegenbase1.rootHeight > biomegenbase.rootHeight) { + f5 /= 2.0F; + } + f += f4 * f5; + f1 += f3 * f5; + f2 += f5; + } + } + f /= f2; + f1 /= f2; + f = f * 0.9F + 0.1F; + f1 = (f1 * 4.0F - 1.0F) / 8.0F; + double d12 = this.noise5[i1] / 8000.0D; + if (d12 < 0.0D) { + d12 = -d12 * 0.3D; + } + d12 = d12 * 3.0D - 2.0D; + if (d12 < 0.0D) { + d12 /= 2.0D; + if (d12 < -1.0D) { + d12 = -1.0D; + } + d12 /= 1.4D; + d12 /= 2.0D; + } else { + if (d12 > 1.0D) { + d12 = 1.0D; + } + d12 /= 8.0D; + } + ++i1; + double d13 = f1; + double d14 = f; + d13 += d12 * 0.2D; + d13 = d13 * 8.5D / 8.0D; + double d5 = 8.5D + d13 * 4.0D; + for (int j2 = 0; j2 < 33; ++j2) { + double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14; + if (d6 < 0.0D) { + d6 *= 4.0D; + } + double d7 = this.noise1[l] / 512.0D; + double d8 = this.noise2[l] / 512.0D; + double d9 = (this.noise3[l] / 10.0D + 1.0D) / 2.0D; + double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; + if (j2 > 29) { + double d11 = (j2 - 29) / 3.0F; + d10 = d10 * (1.0D - d11) + -10.0D * d11; + } + this.noiseArray[l] = d10; + ++l; + } + } + } + } + + /** + * Checks to see if a chunk exists at x, y + */ + @Override + public boolean chunkExists(int par1, int par2) { + return true; + } + + /** + * Populates chunk with ores etc etc + */ + @Override + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { + BlockFalling.fallInstantly = true; + int k = par2 * 16; + int l = par3 * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + this.rand.setSeed(this.worldObj.getSeed()); + long i1 = this.rand.nextLong() / 2L * 2L + 1L; + long j1 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed(par2 * i1 + par3 * j1 ^ this.worldObj.getSeed()); + boolean flag = false; + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + + //Enable map features ?? + if (this.mapFeaturesEnabled) { + this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + } + int k1; + int l1; + int i2; + + //Add Cryotheum Lakes + if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag && this.rand.nextInt(4) == 0 + && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAKE)) { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(256); + i2 = l + this.rand.nextInt(16) + 8; + (new WorldGenLakes(TF_Blocks.blockFluidCryotheum)).generate(this.worldObj, this.rand, k1, l1, i2); + } + + //Add Pyrotheum Lakes + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAVA) && !flag && this.rand.nextInt(8) == 0) { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); + i2 = l + this.rand.nextInt(16) + 8; + + if (l1 < 63 || this.rand.nextInt(10) == 0) { + (new WorldGenLakes(TF_Blocks.blockFluidPyrotheum)).generate(this.worldObj, this.rand, k1, l1, i2); + } + } + + //Add Ender Lakes + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAVA) && !flag && this.rand.nextInt(8) == 0) { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); + i2 = l + this.rand.nextInt(16) + 8; + + if (l1 < 63 || this.rand.nextInt(10) == 0) { + (new WorldGenLakes(TF_Blocks.blockFluidEnder)).generate(this.worldObj, this.rand, k1, l1, i2); + } + } + + //Add Dungeons ?? + boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, DUNGEON); + for (k1 = 0; doGen && k1 < 8; ++k1) { + l1 = k + this.rand.nextInt(16) + 8; + i2 = this.rand.nextInt(256); + int j2 = l + this.rand.nextInt(16) + 8; + (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); + } + + //Add Animals ?? + biomegenbase.decorate(this.worldObj, this.rand, k, l); + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { + SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); + } + k += 8; + l += 8; + + //Creates snow and ice in world. + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ICE); + for (k1 = 0; doGen && k1 < 16; ++k1) { + for (l1 = 0; l1 < 16; ++l1) { + i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1); + + if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) { + this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); + } + + if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true)) { + this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); + } + } + } + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + BlockFalling.fallInstantly = false; + } + + /** + * Two modes of operation: if passed true, save all Chunks in one go. If passed false, save up to two chunks. + * Return true if all chunks have been saved. + */ + @Override + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) { + return true; + } + + /** + * Save extra data not associated with any Chunk. Not saved during autosave, only during world unload. Currently + * unimplemented. + */ + @Override + public void saveExtraData() {} + + /** + * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk. + */ + @Override + public boolean unloadQueuedChunks() { + return false; + } + + /** + * Returns if the IChunkProvider supports saving. + */ + @Override + public boolean canSave() { + return true; + } + + /** + * Converts the instance data to a readable string. + */ + @Override + public String makeString() { + return "RandomLevelSource"; + } + + /** + * Returns a list of creatures of the specified type that can spawn at the given location. + */ + @SuppressWarnings("rawtypes") + @Override + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.func_143030_a(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + @Override + public int getLoadedChunkCount() { + return 0; + } + + @Override + public void recreateStructures(int par1, int par2) { + if (this.mapFeaturesEnabled) { + //this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + } + } + + /** + * Returns the location of the closest structure of the specified type. If + * not found returns null. + */ + @Override + // TODO: findClosestStructure + public ChunkPosition func_147416_a(World world, String arg1, int arg2, int arg3, int arg4) { + return null; + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/Dimension.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/Dimension.java new file mode 100644 index 0000000000..d65b7e9a92 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/Dimension.java @@ -0,0 +1,22 @@ +package gtPlusPlus.core.world.dimensionA.world; + +import gtPlusPlus.core.world.DimensionIDs; +import net.minecraftforge.common.DimensionManager; + +public class Dimension { + + /** + * Register dimensions. + * @param register + */ + public static void registerDimensions(){ + DimensionManager.registerDimension(DimensionIDs.Dimension_A, DimensionIDs.Dimension_A); + } + + /** + * Regster dimension world providers with the dimension manager. + */ + public static void registerWorldProvider(){ + DimensionManager.registerProviderType(DimensionIDs.Dimension_A, WorldProviderForest.class, true); + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldChunkManagerForest.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldChunkManagerForest.java new file mode 100644 index 0000000000..9808d4c2d4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldChunkManagerForest.java @@ -0,0 +1,288 @@ +package gtPlusPlus.core.world.dimensionA.world; + +import java.util.*; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.world.dimensionA.world.genlayer.LightForestGenLayer; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; +import net.minecraft.world.*; +import net.minecraft.world.biome.*; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; + +public class WorldChunkManagerForest extends WorldChunkManager { + + private GenLayer genBiomes; + /** A GenLayer containing the indices into BiomeGenBase.biomeList[] */ + private GenLayer biomeIndexLayer; + /** The BiomeCache object for this world. */ + private BiomeCache biomeCache; + /** A list of biomes that the player can spawn in. */ + private List<BiomeGenBase> biomesToSpawnIn; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public WorldChunkManagerForest() + { + this.biomeCache = new BiomeCache(this); + this.biomesToSpawnIn = new ArrayList(); + this.biomesToSpawnIn.addAll(allowedBiomes); + } + + public WorldChunkManagerForest(long seed, WorldType worldType) + { + this(); + // i changed this to my GenLayerTutorial + GenLayer[] agenlayer = LightForestGenLayer.makeTheWorld(seed, worldType); + agenlayer = getModdedBiomeGenerators(worldType, seed, agenlayer); + this.genBiomes = agenlayer[0]; + this.biomeIndexLayer = agenlayer[1]; + } + + public WorldChunkManagerForest(World world) + { + this(world.getSeed(), world.getWorldInfo().getTerrainType()); + } + + /** + * Gets the list of valid biomes for the player to spawn in. + */ + @Override + public List<BiomeGenBase> getBiomesToSpawnIn() + { + return this.biomesToSpawnIn; + } + + /** + * Returns the BiomeGenBase related to the x, z position on the world. + */ + @Override + public BiomeGenBase getBiomeGenAt(int x, int z) + { + return this.biomeCache.getBiomeGenAt(x, z); + } + + /** + * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length. + */ + @Override + public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) + { + IntCache.resetIntCache(); + + if (listToReuse == null || listToReuse.length < width * length) + { + listToReuse = new float[width * length]; + } + + int[] aint = this.biomeIndexLayer.getInts(x, z, width, length); + + for (int i1 = 0; i1 < width * length; ++i1) + { + try + { + float f = BiomeGenBase.getBiome(aint[i1]).getIntRainfall() / 65536.0F; + + if (f > 1.0F) + { + f = 1.0F; + } + + listToReuse[i1] = f; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("DownfallBlock"); + crashreportcategory.addCrashSection("biome id", Integer.valueOf(i1)); + crashreportcategory.addCrashSection("downfalls[] size", Integer.valueOf(listToReuse.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(x)); + crashreportcategory.addCrashSection("z", Integer.valueOf(z)); + crashreportcategory.addCrashSection("w", Integer.valueOf(width)); + crashreportcategory.addCrashSection("h", Integer.valueOf(length)); + throw new ReportedException(crashreport); + } + } + + return listToReuse; + } + + /** + * Return an adjusted version of a given temperature based on the y height + */ + @Override + @SideOnly(Side.CLIENT) + public float getTemperatureAtHeight(float par1, int par2) + { + return par1; + } + + /** + * Returns an array of biomes for the location input. + */ + @Override + public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + IntCache.resetIntCache(); + + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + int[] aint = this.genBiomes.getInts(par2, par3, par4, par5); + + try + { + for (int i = 0; i < par4 * par5; ++i) + { + par1ArrayOfBiomeGenBase[i] = BiomeGenBase.getBiome(aint[i]); + } + + return par1ArrayOfBiomeGenBase; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock"); + crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(par1ArrayOfBiomeGenBase.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("z", Integer.valueOf(par3)); + crashreportcategory.addCrashSection("w", Integer.valueOf(par4)); + crashreportcategory.addCrashSection("h", Integer.valueOf(par5)); + throw new ReportedException(crashreport); + } + } + + /** + * Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the + * WorldChunkManager Args: oldBiomeList, x, z, width, depth + */ + @Override + public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] oldBiomeList, int x, int z, int width, int depth) + { + return this.getBiomeGenAt(oldBiomeList, x, z, width, depth, true); + } + + /** + * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, + * don't check biomeCache to avoid infinite loop in BiomeCacheBlock) + */ + @Override + public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] listToReuse, int x, int y, int width, int length, boolean cacheFlag) + { + IntCache.resetIntCache(); + + if (listToReuse == null || listToReuse.length < width * length) + { + listToReuse = new BiomeGenBase[width * length]; + } + + if (cacheFlag && width == 16 && length == 16 && (x & 15) == 0 && (y & 15) == 0) + { + BiomeGenBase[] abiomegenbase1 = this.biomeCache.getCachedBiomes(x, y); + System.arraycopy(abiomegenbase1, 0, listToReuse, 0, width * length); + return listToReuse; + } + else + { + int[] aint = this.biomeIndexLayer.getInts(x, y, width, length); + + for (int i = 0; i < width * length; ++i) + { + listToReuse[i] = BiomeGenBase.getBiome(aint[i]); + } + return listToReuse; + } + } + + /** + * checks given Chunk's Biomes against List of allowed ones + */ + @Override + @SuppressWarnings("rawtypes") + public boolean areBiomesViable(int x, int y, int z, List par4List) + { + IntCache.resetIntCache(); + int l = x - z >> 2; + int i1 = y - z >> 2; + int j1 = x + z >> 2; + int k1 = y + z >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + + try + { + for (int j2 = 0; j2 < l1 * i2; ++j2) + { + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[j2]); + + if (!par4List.contains(biomegenbase)) + { + return false; + } + } + + return true; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer"); + crashreportcategory.addCrashSection("Layer", this.genBiomes.toString()); + crashreportcategory.addCrashSection("x", Integer.valueOf(x)); + crashreportcategory.addCrashSection("z", Integer.valueOf(y)); + crashreportcategory.addCrashSection("radius", Integer.valueOf(z)); + crashreportcategory.addCrashSection("allowed", par4List); + throw new ReportedException(crashreport); + } + } + + /** + * Finds a valid position within a range, that is in one of the listed + * biomes. Searches {par1,par2} +-par3 blocks. Strongly favors positive y + * positions. + */ + @Override + @SuppressWarnings("rawtypes") + public ChunkPosition findBiomePosition(int x, int y, int z, List par4List, Random random) + { + IntCache.resetIntCache(); + int l = x - z >> 2; + int i1 = y - z >> 2; + int j1 = x + z >> 2; + int k1 = y + z >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + ChunkPosition chunkposition = null; + int j2 = 0; + + for (int k2 = 0; k2 < l1 * i2; ++k2) + { + int l2 = l + k2 % l1 << 2; + int i3 = i1 + k2 / l1 << 2; + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[k2]); + + if (par4List.contains(biomegenbase) && (chunkposition == null || random.nextInt(j2 + 1) == 0)) + { + chunkposition = new ChunkPosition(l2, 0, i3); + ++j2; + } + } + + return chunkposition; + } + + /** + * Calls the WorldChunkManager's biomeCache.cleanupCache() + */ + @Override + public void cleanupCache() + { + this.biomeCache.cleanupCache(); + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldProviderForest.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldProviderForest.java new file mode 100644 index 0000000000..e543391a70 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldProviderForest.java @@ -0,0 +1,217 @@ +package gtPlusPlus.core.world.dimensionA.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.world.DimensionIDs; +import gtPlusPlus.core.world.dimensionA.world.renderers.*; +import net.minecraft.entity.Entity; +import net.minecraft.util.*; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.common.DimensionManager; + +public class WorldProviderForest extends WorldProvider{ + + @Override + /** tells Minecraft to use our new Terrain Generator */ + public IChunkProvider createChunkGenerator() { + return new ChunkProviderForest(this.worldObj, this.worldObj.getSeed(), true); + } + + @Override + /** tells Minecraft to use our new WorldChunkManager **/ + public void registerWorldChunkManager() { + this.worldChunkMgr = new WorldChunkManagerForest(worldObj.getSeed(), terrainType); + this.dimensionId = DimensionIDs.Dimension_A; + } + + /** Get Provider for Dimension **/ + public static WorldProvider getProviderForDimension(int id) + { + return DimensionManager.createProviderFor(DimensionIDs.Dimension_A); + } + + @Override + /** + * @return the name of the dimension + */ + public String getDimensionName() { + return "Light Forest"; + } + + @Override + /** sets/creates the save folder */ + public String getSaveFolder() { + return "DIM" + DimensionIDs.Dimension_A; + } + + @SideOnly(Side.CLIENT) + /** should stars be rendered? */ + public boolean renderStars() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + /** @return the player speed */ + public double getMovementFactor() { + return 0.1; + } + + @SideOnly(Side.CLIENT) + /** @return the light value of the stars*/ + public float getStarBrightness(World world, float f) { + return 1.0F; + } + + @SideOnly(Side.CLIENT) + /** should clouds be rendered? */ + public boolean renderClouds() { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean renderVoidFog() { + return false; + } + + @SideOnly(Side.CLIENT) + /** should the end sky be rendered or the overworld sky? */ + public boolean renderEndSky() { + return true; + } + + @SideOnly(Side.CLIENT) + /** @return the size of the sun */ + public float setSunSize() { + return 0.5F; + } + + @SideOnly(Side.CLIENT) + /** @return the size of the moon */ + public float setMoonSize() { + return 4.0F; + } + + @Override + @SideOnly(Side.CLIENT) + /** + * @return the sky color + */ + public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) { + return worldObj.getSkyColorBody(cameraEntity, partialTicks); + } + + @Override + @SideOnly(Side.CLIENT) + /** should a color for the sky be rendered? */ + public boolean isSkyColored() + { + return true; + } + + @Override + /** can the player respawn in this dimension? */ + public boolean canRespawnHere() + { + return true; + } + + @Override + /** is this a surface world or an underworld */ + public boolean isSurfaceWorld() + { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + /** @return the high of the clouds */ + public float getCloudHeight() + { + return this.terrainType.getCloudHeight(); + } + + @Override + public ChunkCoordinates getEntrancePortalLocation() + { + return new ChunkCoordinates(50, 5, 0); + } + + @Override + /** the light value in this dimension */ + protected void generateLightBrightnessTable() + { + float f = 0.0F; + + for (int i = 0; i <= 15; ++i) + { + float f1 = 1.0F - i / 15.0F; + this.lightBrightnessTable[i] = (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f; + } + } + + @Override + @SideOnly(Side.CLIENT) + /** @return the dimension join message */ + public String getWelcomeMessage() + { + return "Entering the Forest"; + } + + @Override + @SideOnly(Side.CLIENT) + /** @return the dimension leave message */ + public String getDepartMessage() + { + return "Leaving the Forest"; + } + + @Override + public IRenderHandler getSkyRenderer() { + return new SkyRenderer(); + } + + @Override + public IRenderHandler getCloudRenderer() { + return new CloudRenderer(); + } + + @Override + public IRenderHandler getWeatherRenderer() { + return new WeatherRenderer(); + } + + @Override + public Vec3 drawClouds(float partialTicks) { + // TODO Auto-generated method stub + return super.drawClouds(partialTicks); + } + + @Override + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1, float par2) + { + float f2 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + float f3 = 0.7529412F; + float f4 = 0.84705883F; + float f5 = 1.0F; + f3 *= f2 * 0.94F + 0.06F; + f4 *= f2 * 0.94F + 0.06F; + f5 *= f2 * 0.91F + 0.09F; + return Vec3.createVectorHelper(f3, f4, f5); + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldTypesTutorial.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldTypesTutorial.java new file mode 100644 index 0000000000..722ca4c2f3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/WorldTypesTutorial.java @@ -0,0 +1,59 @@ +package gtPlusPlus.core.world.dimensionA.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.*; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderGenerate; + +public class WorldTypesTutorial extends WorldType{ + + private boolean hasNotificationData; + + public static WorldType tutDimOverWorld; + + public WorldTypesTutorial(String name) { + super(name); + } + + public static void addCustomWorldTypes(){ + tutDimOverWorld = new WorldTypesTutorial("TUTORIAL").setNotificationData(); + } + + @Override + public WorldChunkManager getChunkManager(World world) { + return new WorldChunkManagerHell(BiomeGenBase.megaTaiga, 0.5F); + } + + @Override + public IChunkProvider getChunkGenerator(World world, String generatorOptions) { + return new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()); + } + + @Override + public int getMinimumSpawnHeight(World world) { + return 64; + } + + /** + * enables the display of generator.[worldtype].info message on the customize world menu + */ + private WorldType setNotificationData() + { + this.hasNotificationData = true; + return this; + } + + /** + * returns true if selecting this worldtype from the customize menu should display the generator.[worldtype].info + * message + */ + @SideOnly(Side.CLIENT) + @Override + public boolean showWorldInfoNotice() + { + return this.hasNotificationData; + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeDarkForest.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeDarkForest.java new file mode 100644 index 0000000000..f64ca7faf5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeDarkForest.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes; + +import java.util.Random; + +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class BiomeDarkForest extends ModBiomes{ + + public BiomeDarkForest(int biomeId) { + super(biomeId); + this.theBiomeDecorator.treesPerChunk = 30; + this.theBiomeDecorator.grassPerChunk = 5; + this.theBiomeDecorator.flowersPerChunk = 1; + + this.topBlock = Blocks.grass; + this.fillerBlock = Blocks.dirt; + } + + /** + * Remove this to remove vines from dimension + */ + @Override + public void decorate(World world, Random random, int par3, int par4) { + super.decorate(world, random, par3, par4); +// WorldGenVines worldgenvines = new WorldGenVines(); +// +// for (int k = 0; k < 50; ++k) { +// int l = par3 + random.nextInt(16) + 8; +// byte b0 = 64; +// int i1 = par4 + random.nextInt(16) + 8; +// worldgenvines.generate(world, random, l, b0, i1); +// } + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeIDs.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeIDs.java new file mode 100644 index 0000000000..4e15fb9cf3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeIDs.java @@ -0,0 +1,8 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes; + +public class BiomeIDs { + + public static int LIGHT; + public static int DARK; + public static int BLUE; +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeLightForest.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeLightForest.java new file mode 100644 index 0000000000..5891a4fc2f --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeLightForest.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes; + +import java.util.Random; + +import gtPlusPlus.core.world.dimensionA.world.biomes.decorators.BiomeDecoratorMod; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenTallGrass; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BiomeLightForest extends ModBiomes{ + + public static int treesPerChunk; + + protected BiomeDecoratorMod decorator; + + public BiomeLightForest(int biomeId) { + super(biomeId); + BiomeLightForest.treesPerChunk = 2; + this.topBlock = Blocks.grass; + this.fillerBlock = Blocks.dirt; + } + + /** + * Gets a WorldGen appropriate for this biome. + */ + @Override + public WorldGenerator getRandomWorldGenForGrass(Random random){ + return random.nextInt(2) == 0 ? new WorldGenTallGrass(Blocks.tallgrass, 1) : new WorldGenTallGrass(Blocks.tallgrass, 2); + } + + /** + * Remove this to remove vines from dimension + */ + @Override + public void decorate(World world, Random random, int par3, int par4) { + super.decorate(world, random, par3, par4); +// WorldGenVines worldgenvines = new WorldGenVines(); +// +// for (int k = 0; k < 50; ++k) { +// int l = par3 + random.nextInt(16) + 8; +// byte b0 = 64; +// int i1 = par4 + random.nextInt(16) + 8; +// worldgenvines.generate(world, random, l, b0, i1); +// } + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/ModBiomes.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/ModBiomes.java new file mode 100644 index 0000000000..596723d33c --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/ModBiomes.java @@ -0,0 +1,165 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes; + +import java.util.Random; + +import gtPlusPlus.core.world.dimensionA.world.biomes.decorators.BiomeDecoratorMod; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenTallGrass; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; + +/** + * TutorialBiomes.class Holds and loads all Tutorial Biomes. + * + * @author Jimmy04Creeper + */ +public class ModBiomes extends BiomeGenBase { + + /** The biome height */ + public static final BiomeGenBase.Height biomeHeight = new BiomeGenBase.Height(0.3F, 0.6F); + + public static BiomeGenBase forestLight; + public static BiomeGenBase forestDark; + + public ModBiomes(int biomeId) { + super(biomeId); + this.theBiomeDecorator = new BiomeDecoratorMod(); + } + + static { + forestLight = (new BiomeLightForest(BiomeIDs.LIGHT).setColor(5470985).setTemperatureRainfall(0.95F, 0.9F).setHeight(biomeHeight).setBiomeName("Forest Of Light")); + forestDark = (new BiomeDarkForest(BiomeIDs.DARK).setColor(34049320).setTemperatureRainfall(0.8F, 0.4F).setHeight(biomeHeight).setBiomeName("Darkness Forest")); + } + + @Override + public WorldGenerator getRandomWorldGenForGrass(Random random) + { + if (random.nextInt(4) == 0) + return new WorldGenTallGrass(Blocks.tallgrass, 2); + else + return new WorldGenTallGrass(Blocks.tallgrass, 1); + } + + public static void registerWithBiomeDictionary() + { + BiomeDictionary.registerBiomeType(forestLight, Type.FOREST); + BiomeDictionary.registerBiomeType(forestDark, Type.SAVANNA); + BiomeDictionary.registerAllBiomes(); + } + + @Override + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) { + genBiomeModdedTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + /** + * Replaces custom Stone to allow top/filler blocks to work in dimension. + * + * @param world + * @param random + * @param replacableBlock + * @param aByte + * @param x + * @param y + * @param z + */ + public void genBiomeModdedTerrain(World world, Random random, Block[] replacableBlock, byte[] aByte, int x, int y, double z) + { + Block block = this.topBlock; + byte b0 = (byte) (this.field_150604_aj & 255); + Block block1 = this.fillerBlock; + int k = -1; + int l = (int) (z / 3.0D + 3.0D + random.nextDouble() * 0.25D); + int i1 = x & 15; + int j1 = y & 15; + int k1 = replacableBlock.length / 256; + for (int l1 = 255; l1 >= 0; --l1) + { + int i2 = (j1 * 16 + i1) * k1 + l1; + + if (l1 <= 0 + random.nextInt(5)) + { + replacableBlock[i2] = Blocks.bedrock; + } + else + { + Block block2 = replacableBlock[i2]; + + if (block2 != null && block2.getMaterial() != Material.air) + { + if (block2 == Blocks.stone) + { + if (k == -1) + { + if (l <= 0) + { + block = null; + b0 = 0; + block1 = Blocks.stone; + } + else if (l1 >= 59 && l1 <= 64) + { + block = this.topBlock; + b0 = (byte) (this.field_150604_aj & 255); + block1 = this.fillerBlock; + } + + if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) + { + if (this.getFloatTemperature(x, l1, y) < 0.15F) + { + block = Blocks.ice; + b0 = 0; + } + else + { + block = Blocks.water; + b0 = 0; + } + } + + k = l; + + if (l1 >= 62) + { + replacableBlock[i2] = block; + aByte[i2] = b0; + } + else if (l1 < 56 - l) + { + block = null; + block1 = Blocks.stone; + replacableBlock[i2] = Blocks.gravel; + } + else + { + replacableBlock[i2] = block1; + } + } + else if (k > 0) + { + --k; + replacableBlock[i2] = block1; + + if (k == 0 && block1 == Blocks.sand) + { + k = random.nextInt(4) + Math.max(0, l1 - 63); + block1 = Blocks.sandstone; + } + } + } + } + else + { + k = -1; + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorHelper.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorHelper.java new file mode 100644 index 0000000000..3f0443ec74 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorHelper.java @@ -0,0 +1,105 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes.decorators; + +import gtPlusPlus.core.world.dimensionA.world.biomes.BiomeLightForest; +import gtPlusPlus.core.world.dimensionA.world.biomes.ModBiomes; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent; + +public class BiomeDecoratorHelper { + + private static WorldGenerator glowStone; + + public BiomeDecoratorHelper(){ + // glowStone = new WorldGenMinable(Blocks.glowstone, 30, Blockss.lightStone); + } + + protected static void decorateBiome(BiomeGenBase biome) { + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, BiomeDecoratorMod.chunk_X, BiomeDecoratorMod.chunk_Z)); + //perpere ores for generation + initOres(); + //GenerateOres + generateOreInBiome(biome); + + if(biome == ModBiomes.forestLight){ + BiomeDecoratorMod.howMenyTrees = BiomeLightForest.treesPerChunk; + int i = BiomeDecoratorMod.howMenyTrees; + /** Chunk Postions **/ + int chunkX; + int chunkZ; + int y; + /** get blocks at the given locations **/ + Block block; + Block blockA; + /** Generates Small tree **/ + for(int a = 0; a < i; ++a){ + if(i == BiomeDecoratorMod.randomGenerator.nextInt(8)){ + chunkX = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8; + chunkZ = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8; + y = BiomeDecoratorMod.currentWorld.getTopSolidOrLiquidBlock(chunkX, chunkZ); + block = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y, chunkZ); + blockA = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y - 1, chunkZ); + if(block != Blocks.air || block != Blocks.water){ + if(blockA != Blocks.air || blockA != Blocks.water){ + BiomeDecoratorMod.smallTree.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, chunkX, y, chunkZ); + } + } + } + /** Generates Big tree **/ + if(i == BiomeDecoratorMod.randomGenerator.nextInt(15)){ + chunkX = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8; + chunkZ = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8; + y = BiomeDecoratorMod.currentWorld.getTopSolidOrLiquidBlock(chunkX, chunkZ); + block = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y, chunkZ); + blockA = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y - 1, chunkZ); + if(block != Blocks.air || block != Blocks.water){ + if(blockA != Blocks.air || blockA != Blocks.water){ + BiomeDecoratorMod.bigTree.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, chunkX, y, chunkZ); + } + } + } + } + if(biome == ModBiomes.forestDark){ + //GENERARTE DARK FOREST STUFF HERE + } + } + } + + /** + * Prepare ores for generation + */ + private static void initOres() { + //glowstone used fotr testing generation + glowStone = new WorldGenMinable(Blocks.glowstone, 30, Blocks.stone); + } + + /** + * Geberate Ores In a Biome + * @param biome + */ + private static void generateOreInBiome(BiomeGenBase biome){ + if(biome == ModBiomes.forestLight){ + genStandardOre(20, glowStone, 0, 128); + } + } + + /** + * Generate ores in chunks. + * @param spawnWeight + * @param generatorToSpawn + * @param minSpawnHeight + * @param maxYSpawnHeight + */ + private static void genStandardOre(int spawnWeight, WorldGenerator generatorToSpawn, int minSpawnHeight, int maxYSpawnHeight) { + for (int l = 0; l < spawnWeight; ++l) { + int i1 = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16); + int j1 = BiomeDecoratorMod.randomGenerator.nextInt(maxYSpawnHeight - minSpawnHeight) + minSpawnHeight; + int k1 = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16); + generatorToSpawn.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, i1, j1, k1); + } + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorMod.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorMod.java new file mode 100644 index 0000000000..f80f9b0093 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorMod.java @@ -0,0 +1,73 @@ +package gtPlusPlus.core.world.dimensionA.world.biomes.decorators; + +import java.util.Random; + +import gtPlusPlus.core.world.dimensionA.world.gen.*; +import gtPlusPlus.xmod.gregtech.api.objects.XSTR; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenMinable; + +public class BiomeDecoratorMod extends BiomeDecorator +{ + /** The world the BiomeDecorator is currently decorating */ + public static World currentWorld; + /** The Biome Decorator's random number generator. */ + public static XSTR randomGenerator; + /** The X-coordinate of the chunk currently being decorated */ + public static int chunk_X; + /** The Z-coordinate of the chunk currently being decorated */ + public static int chunk_Z; + /** True if decorator should generate surface lava & water */ + public static boolean generateLakes; + /** How meny trees per chunk, set in each biome class **/ + public static int howMenyTrees; + + /** Dimension Trees **/ + public static WorldGenForestTrees smallTree; + public static WorldGenForestBigTree bigTree; + public static WorldGenEffectTree effectTree; + + public BiomeDecoratorMod() { + coalGen = new WorldGenMinable(Blocks.coal_ore, 16, Blocks.stone); + ironGen = new WorldGenMinable(Blocks.iron_ore, 8, Blocks.stone); + goldGen = new WorldGenMinable(Blocks.gold_ore, 8, Blocks.stone); + redstoneGen = new WorldGenMinable(Blocks.redstone_ore, 7, Blocks.stone); + diamondGen = new WorldGenMinable(Blocks.diamond_ore, 7, Blocks.stone); + lapisGen = new WorldGenMinable(Blocks.lapis_ore, 6, Blocks.stone); + + // TREES + smallTree = new WorldGenForestTrees(true); + bigTree = new WorldGenForestBigTree(true, 10, 1, 5); + effectTree = new WorldGenEffectTree(true); + + // generates lakes and lava lakes in dimension. + generateLakes = true; + } + + @Override + public void decorateChunk(World world, Random random, BiomeGenBase biomeGenBase, int chunkX, int chunkZ) { + if (currentWorld != null) { + throw new RuntimeException("Already decorating!!"); + } else { + currentWorld = world; + randomGenerator = (XSTR) random; + chunk_X = chunkX; + chunk_Z = chunkZ; + genDecorationsForBiome(biomeGenBase); + currentWorld = null; + randomGenerator = null; + } + } + + /** + * Decorate's biome. + * + * @param biome + */ + protected void genDecorationsForBiome(BiomeGenBase biome) { + BiomeDecoratorHelper.decorateBiome(biome); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenEffectTree.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenEffectTree.java new file mode 100644 index 0000000000..7688bda41d --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenEffectTree.java @@ -0,0 +1,212 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenEffectTree extends WorldGenForestAbstractTree +{ + private Block log = Blocks.log; + private Block leaves = Blocks.leaves; + + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000432"; + + public WorldGenEffectTree(boolean p_i45463_1_) { + super(p_i45463_1_); + } + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) { + int l = p_76484_2_.nextInt(3) + p_76484_2_.nextInt(3) + 5; + boolean flag = true; + + if (p_76484_4_ >= 1 && p_76484_4_ + l + 1 <= 256) + { + int j1; + int k1; + + for (int i1 = p_76484_4_; i1 <= p_76484_4_ + 1 + l; ++i1) + { + byte b0 = 1; + + if (i1 == p_76484_4_) + { + b0 = 0; + } + + if (i1 >= p_76484_4_ + 1 + l - 2) + { + b0 = 2; + } + + for (j1 = p_76484_3_ - b0; j1 <= p_76484_3_ + b0 && flag; ++j1) + { + for (k1 = p_76484_5_ - b0; k1 <= p_76484_5_ + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + @SuppressWarnings("unused") + Block block = p_76484_1_.getBlock(j1, i1, k1); + + if (!this.isReplaceable(p_76484_1_, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block3 = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ - 1, p_76484_5_); + + boolean isSoil = block3.canSustainPlant(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, ForgeDirection.UP, (IPlantable)Blocks.sapling); + if (isSoil && p_76484_4_ < 256 - l - 1) + { + block3.onPlantGrow(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, p_76484_3_, p_76484_4_, p_76484_5_); + int j3 = p_76484_2_.nextInt(4); + j1 = l - p_76484_2_.nextInt(4) - 1; + k1 = 3 - p_76484_2_.nextInt(3); + int k3 = p_76484_3_; + int l1 = p_76484_5_; + int i2 = 0; + int j2; + int k2; + + for (j2 = 0; j2 < l; ++j2) + { + k2 = p_76484_4_ + j2; + + if (j2 >= j1 && k1 > 0) + { + k3 += Direction.offsetX[j3]; + l1 += Direction.offsetZ[j3]; + --k1; + } + + Block block1 = p_76484_1_.getBlock(k3, k2, l1); + + if (block1.isAir(p_76484_1_, k3, k2, l1) || block1.isLeaves(p_76484_1_, k3, k2, l1)) + { + this.setBlockAndNotifyAdequately(p_76484_1_, k3, k2, l1, log, 0); + i2 = k2; + } + } + + for (j2 = -1; j2 <= 1; ++j2) + { + for (k2 = -1; k2 <= 1; ++k2) + { + this.func_150525_a(p_76484_1_, k3 + j2, i2 + 1, l1 + k2); + } + } + + this.func_150525_a(p_76484_1_, k3 + 2, i2 + 1, l1); + this.func_150525_a(p_76484_1_, k3 - 2, i2 + 1, l1); + this.func_150525_a(p_76484_1_, k3, i2 + 1, l1 + 2); + this.func_150525_a(p_76484_1_, k3, i2 + 1, l1 - 2); + + for (j2 = -3; j2 <= 3; ++j2) + { + for (k2 = -3; k2 <= 3; ++k2) + { + if (Math.abs(j2) != 3 || Math.abs(k2) != 3) + { + this.func_150525_a(p_76484_1_, k3 + j2, i2, l1 + k2); + } + } + } + + k3 = p_76484_3_; + l1 = p_76484_5_; + j2 = p_76484_2_.nextInt(4); + + if (j2 != j3) + { + k2 = j1 - p_76484_2_.nextInt(2) - 1; + int l3 = 1 + p_76484_2_.nextInt(3); + i2 = 0; + int l2; + int i3; + + for (l2 = k2; l2 < l && l3 > 0; --l3) + { + if (l2 >= 1) + { + i3 = p_76484_4_ + l2; + k3 += Direction.offsetX[j2]; + l1 += Direction.offsetZ[j2]; + Block block2 = p_76484_1_.getBlock(k3, i3, l1); + + if (block2.isAir(p_76484_1_, k3, i3, l1) || block2.isLeaves(p_76484_1_, k3, i3, l1)) + { + this.setBlockAndNotifyAdequately(p_76484_1_, k3, i3, l1, log, 0); + i2 = i3; + } + } + + ++l2; + } + + if (i2 > 0) + { + for (l2 = -1; l2 <= 1; ++l2) + { + for (i3 = -1; i3 <= 1; ++i3) + { + this.func_150525_a(p_76484_1_, k3 + l2, i2 + 1, l1 + i3); + } + } + + for (l2 = -2; l2 <= 2; ++l2) + { + for (i3 = -2; i3 <= 2; ++i3) + { + if (Math.abs(l2) != 2 || Math.abs(i3) != 2) + { + this.func_150525_a(p_76484_1_, k3 + l2, i2, l1 + i3); + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private void func_150525_a(World p_150525_1_, int p_150525_2_, int p_150525_3_, int p_150525_4_) + { + Block block = p_150525_1_.getBlock(p_150525_2_, p_150525_3_, p_150525_4_); + + if (block.isAir(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_) || block.isLeaves(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_)) + { + this.setBlockAndNotifyAdequately(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_, leaves, 0); + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestAbstractTree.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestAbstractTree.java new file mode 100644 index 0000000000..1cbdab8f5d --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestAbstractTree.java @@ -0,0 +1,33 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public abstract class WorldGenForestAbstractTree extends WorldGenerator +{ + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000399"; + + public WorldGenForestAbstractTree(boolean p_i45448_1_) + { + super(p_i45448_1_); + } + + protected boolean func_150523_a(Block p_150523_1_) + { + return p_150523_1_.getMaterial() == Material.air || p_150523_1_.getMaterial() == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine; + } + + public void func_150524_b(World p_150524_1_, Random p_150524_2_, int p_150524_3_, int p_150524_4_, int p_150524_5_) {} + + protected boolean isReplaceable(World world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + return block.isAir(world, x, y, z) || block.isLeaves(world, x, y, z) || block.isWood(world, x, y, z) || func_150523_a(block); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestBigTree.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestBigTree.java new file mode 100644 index 0000000000..5121fbc153 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestBigTree.java @@ -0,0 +1,526 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class WorldGenForestBigTree extends WorldGenForestAbstractTree +{ + private static Block log = Blocks.log; + private static Block leaves = Blocks.leaves; + + /** + * Contains three sets of two values that provide complimentary indices for + * a given 'major' index - 1 and 2 for 0, 0 and 2 for 1, and 0 and 1 for 2. + */ + static final byte[] otherCoordPairs = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1 }; + /** random seed for GenBigTree */ + Random rand = new Random(); + /** Reference to the World object. */ + World worldObj; + int[] basePos = new int[] { 0, 0, 0 }; + int heightLimit; + int height; + double heightAttenuation = 0.618D; + double branchDensity = 1.0D; + double branchSlope = 0.381D; + double scaleWidth = 1.0D; + double leafDensity = 1.0D; + /** + * Currently always 1, can be set to 2 in the class constructor to generate + * a double-sized tree trunk for big trees. + */ + int trunkSize = 1; + /** Sets the limit of the random value used to initialize the height limit. */ + int heightLimitLimit = 12; + /** + * Sets the distance limit for how far away the generator will populate + * leaves from the base leaf node. + */ + int leafDistanceLimit = 4; + /** Contains a list of a points at which to generate groups of leaves. */ + int[][] leafNodes; + + public WorldGenForestBigTree(boolean p_i2008_1_, int treeHeight, int trunkWidth, int leavesWidthFromBase) + { + super(p_i2008_1_); + this.trunkSize = trunkWidth; + this.heightLimitLimit = treeHeight; + this.leafDistanceLimit = leavesWidthFromBase; + } + + /** + * Generates a list of leaf nodes for the tree, to be populated by + * generateLeaves. + */ + void generateLeafNodeList() + { + this.height = (int) (this.heightLimit * this.heightAttenuation); + + if (this.height >= this.heightLimit) + { + this.height = this.heightLimit - 1; + } + + int i = (int) (1.382D + Math.pow(this.leafDensity * this.heightLimit / 13.0D, 2.0D)); + + if (i < 1) + { + i = 1; + } + + int[][] aint = new int[i * this.heightLimit][4]; + int j = this.basePos[1] + this.heightLimit - this.leafDistanceLimit; + int k = 1; + int l = this.basePos[1] + this.height; + int i1 = j - this.basePos[1]; + aint[0][0] = this.basePos[0]; + aint[0][1] = j; + aint[0][2] = this.basePos[2]; + aint[0][3] = l; + --j; + + while (i1 >= 0) + { + int j1 = 0; + float f = this.layerSize(i1); + + if (f < 0.0F) + { + --j; + --i1; + } + else + { + for (double d0 = 0.5D; j1 < i; ++j1) + { + double d1 = this.scaleWidth * f * (this.rand.nextFloat() + 0.328D); + double d2 = this.rand.nextFloat() * 2.0D * Math.PI; + int k1 = MathHelper.floor_double(d1 * Math.sin(d2) + this.basePos[0] + d0); + int l1 = MathHelper.floor_double(d1 * Math.cos(d2) + this.basePos[2] + d0); + int[] aint1 = new int[] { k1, j, l1 }; + int[] aint2 = new int[] { k1, j + this.leafDistanceLimit, l1 }; + + if (this.checkBlockLine(aint1, aint2) == -1) + { + int[] aint3 = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] }; + double d3 = Math.sqrt(Math.pow(Math.abs(this.basePos[0] - aint1[0]), 2.0D) + Math.pow(Math.abs(this.basePos[2] - aint1[2]), 2.0D)); + double d4 = d3 * this.branchSlope; + + if (aint1[1] - d4 > l) + { + aint3[1] = l; + } + else + { + aint3[1] = (int) (aint1[1] - d4); + } + + if (this.checkBlockLine(aint3, aint1) == -1) + { + aint[k][0] = k1; + aint[k][1] = j; + aint[k][2] = l1; + aint[k][3] = aint3[1]; + ++k; + } + } + } + + --j; + --i1; + } + } + + this.leafNodes = new int[k][4]; + System.arraycopy(aint, 0, this.leafNodes, 0, k); + } + + void func_150529_a(int p_150529_1_, int p_150529_2_, int p_150529_3_, float p_150529_4_, byte p_150529_5_, Block p_150529_6_) + { + int l = (int) (p_150529_4_ + 0.618D); + byte b1 = otherCoordPairs[p_150529_5_]; + byte b2 = otherCoordPairs[p_150529_5_ + 3]; + int[] aint = new int[] { p_150529_1_, p_150529_2_, p_150529_3_ }; + int[] aint1 = new int[] { 0, 0, 0 }; + int i1 = -l; + int j1 = -l; + + for (aint1[p_150529_5_] = aint[p_150529_5_]; i1 <= l; ++i1) + { + aint1[b1] = aint[b1] + i1; + j1 = -l; + + while (j1 <= l) + { + double d0 = Math.pow(Math.abs(i1) + 0.5D, 2.0D) + Math.pow(Math.abs(j1) + 0.5D, 2.0D); + + if (d0 > p_150529_4_ * p_150529_4_) + { + ++j1; + } + else + { + aint1[b2] = aint[b2] + j1; + Block block1 = this.worldObj.getBlock(aint1[0], aint1[1], aint1[2]); + + if (!block1.isAir(worldObj, aint1[0], aint1[1], aint1[2]) && !block1.isLeaves(worldObj, aint1[0], aint1[1], aint1[2])) + { + ++j1; + } + else + { + this.setBlockAndNotifyAdequately(this.worldObj, aint1[0], aint1[1], aint1[2], p_150529_6_, 0); + ++j1; + } + } + } + } + } + + /** + * Gets the rough size of a layer of the tree. + */ + float layerSize(int p_76490_1_) + { + if (p_76490_1_ < (this.heightLimit) * 0.3D) + { + return -1.618F; + } + else + { + float f = this.heightLimit / 2.0F; + float f1 = this.heightLimit / 2.0F - p_76490_1_; + float f2; + + if (f1 == 0.0F) + { + f2 = f; + } + else if (Math.abs(f1) >= f) + { + f2 = 0.0F; + } + else + { + f2 = (float) Math.sqrt(Math.pow(Math.abs(f), 2.0D) - Math.pow(Math.abs(f1), 2.0D)); + } + + f2 *= 0.5F; + return f2; + } + } + + float leafSize(int p_76495_1_) + { + return p_76495_1_ >= 0 && p_76495_1_ < this.leafDistanceLimit ? (p_76495_1_ != 0 && p_76495_1_ != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F; + } + + /** + * Generates the leaves surrounding an individual entry in the leafNodes + * list. + */ + void generateLeafNode(int p_76491_1_, int p_76491_2_, int p_76491_3_) + { + int l = p_76491_2_; + + for (int i1 = p_76491_2_ + this.leafDistanceLimit; l < i1; ++l) + { + float f = this.leafSize(l - p_76491_2_); + this.func_150529_a(p_76491_1_, l, p_76491_3_, f, (byte) 1, leaves); + } + } + + void func_150530_a(int[] p_150530_1_, int[] p_150530_2_, Block p_150530_3_) + { + int[] aint2 = new int[] { 0, 0, 0 }; + byte b0 = 0; + byte b1; + + for (b1 = 0; b0 < 3; ++b0) + { + aint2[b0] = p_150530_2_[b0] - p_150530_1_[b0]; + + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) + { + b1 = b0; + } + } + + if (aint2[b1] != 0) + { + byte b2 = otherCoordPairs[b1]; + byte b3 = otherCoordPairs[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) + { + b4 = 1; + } + else + { + b4 = -1; + } + + double d0 = (double) aint2[b2] / (double) aint2[b1]; + double d1 = (double) aint2[b3] / (double) aint2[b1]; + int[] aint3 = new int[] { 0, 0, 0 }; + int i = 0; + + for (int j = aint2[b1] + b4; i != j; i += b4) + { + aint3[b1] = MathHelper.floor_double(p_150530_1_[b1] + i + 0.5D); + aint3[b2] = MathHelper.floor_double(p_150530_1_[b2] + i * d0 + 0.5D); + aint3[b3] = MathHelper.floor_double(p_150530_1_[b3] + i * d1 + 0.5D); + byte b5 = 0; + int k = Math.abs(aint3[0] - p_150530_1_[0]); + int l = Math.abs(aint3[2] - p_150530_1_[2]); + int i1 = Math.max(k, l); + + if (i1 > 0) + { + if (k == i1) + { + b5 = 4; + } + else if (l == i1) + { + b5 = 8; + } + } + + this.setBlockAndNotifyAdequately(this.worldObj, aint3[0], aint3[1], aint3[2], p_150530_3_, b5); + } + } + } + + /** + * Generates the leaf portion of the tree as specified by the leafNodes + * list. + */ + void generateLeaves() + { + int i = 0; + + for (int j = this.leafNodes.length; i < j; ++i) + { + int k = this.leafNodes[i][0]; + int l = this.leafNodes[i][1]; + int i1 = this.leafNodes[i][2]; + this.generateLeafNode(k, l, i1); + } + } + + /** + * Indicates whether or not a leaf node requires additional wood to be added + * to preserve integrity. + */ + boolean leafNodeNeedsBase(int p_76493_1_) + { + return p_76493_1_ >= this.heightLimit * 0.2D; + } + + /** + * Places the trunk for the big tree that is being generated. Able to + * generate double-sized trunks by changing a field that is always 1 to 2. + */ + void generateTrunk() + { + int i = this.basePos[0]; + int j = this.basePos[1]; + int k = this.basePos[1] + this.height; + int l = this.basePos[2]; + int[] aint = new int[] { i, j, l }; + int[] aint1 = new int[] { i, k, l }; + this.func_150530_a(aint, aint1, log); + if (this.trunkSize == 2) + { + ++aint[0]; + ++aint1[0]; + this.func_150530_a(aint, aint1, log); + ++aint[2]; + ++aint1[2]; + this.func_150530_a(aint, aint1, log); + aint[0] += -1; + aint1[0] += -1; + this.func_150530_a(aint, aint1, log); + } + } + + /** + * Generates additional wood blocks to fill out the bases of different leaf + * nodes that would otherwise degrade. + */ + void generateLeafNodeBases() + { + int i = 0; + int j = this.leafNodes.length; + + for (int[] aint = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] }; i < j; ++i) + { + int[] aint1 = this.leafNodes[i]; + int[] aint2 = new int[] { aint1[0], aint1[1], aint1[2] }; + aint[1] = aint1[3]; + int k = aint[1] - this.basePos[1]; + + if (this.leafNodeNeedsBase(k)) + { + this.func_150530_a(aint, aint2, log); + } + } + } + + /** + * Checks a line of blocks in the world from the first coordinate to triplet + * to the second, returning the distance (in blocks) before a non-air, + * non-leaf block is encountered and/or the end is encountered. + */ + int checkBlockLine(int[] p_76496_1_, int[] p_76496_2_) + { + int[] aint2 = new int[] { 0, 0, 0 }; + byte b0 = 0; + byte b1; + + for (b1 = 0; b0 < 3; ++b0) + { + aint2[b0] = p_76496_2_[b0] - p_76496_1_[b0]; + + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) + { + b1 = b0; + } + } + + if (aint2[b1] == 0) + { + return -1; + } + else + { + byte b2 = otherCoordPairs[b1]; + byte b3 = otherCoordPairs[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) + { + b4 = 1; + } + else + { + b4 = -1; + } + + double d0 = (double) aint2[b2] / (double) aint2[b1]; + double d1 = (double) aint2[b3] / (double) aint2[b1]; + int[] aint3 = new int[] { 0, 0, 0 }; + int i = 0; + int j; + + for (j = aint2[b1] + b4; i != j; i += b4) + { + aint3[b1] = p_76496_1_[b1] + i; + aint3[b2] = MathHelper.floor_double(p_76496_1_[b2] + i * d0); + aint3[b3] = MathHelper.floor_double(p_76496_1_[b3] + i * d1); + @SuppressWarnings("unused") + Block block = this.worldObj.getBlock(aint3[0], aint3[1], aint3[2]); + + if (!this.isReplaceable(worldObj, aint3[0], aint3[1], aint3[2])) + { + break; + } + } + + return i == j ? -1 : Math.abs(i); + } + } + + /** + * Returns a boolean indicating whether or not the current location for the + * tree, spanning basePos to to the height limit, is valid. + */ + boolean validTreeLocation() + { + int[] aint = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] }; + int[] aint1 = new int[] { this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2] }; + Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]); + boolean isSoil = false; + + if (block == Blocks.grass || block == Blocks.grass) { + isSoil = true; + } + + if (!isSoil) + { + return false; + } + else + { + int i = this.checkBlockLine(aint, aint1); + + if (i == -1) + { + return true; + } + else if (i < 6) + { + return false; + } + else + { + this.heightLimit = i; + return true; + } + } + } + + /** + * Rescales the generator settings, only used in WorldGenBigTree + */ + @Override + public void setScale(double p_76487_1_, double p_76487_3_, double p_76487_5_) + { + this.heightLimitLimit = (int) (p_76487_1_ * 12.0D); + + if (p_76487_1_ > 0.5D) + { + this.leafDistanceLimit = 5; + } + + this.scaleWidth = p_76487_3_; + this.leafDensity = p_76487_5_; + } + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) + { + this.worldObj = p_76484_1_; + long l = p_76484_2_.nextLong(); + this.rand.setSeed(l); + this.basePos[0] = p_76484_3_; + this.basePos[1] = p_76484_4_; + this.basePos[2] = p_76484_5_; + + if (this.heightLimit == 0) + { + this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit); + } + + if (!this.validTreeLocation()) + { + this.worldObj = null; // Fix vanilla Mem leak, holds latest world + return false; + } + else + { + this.generateLeafNodeList(); + this.generateLeaves(); + this.generateTrunk(); + this.generateLeafNodeBases(); + this.worldObj = null; // Fix vanilla Mem leak, holds latest world + return true; + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestGrass.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestGrass.java new file mode 100644 index 0000000000..00e79fc72f --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestGrass.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class WorldGenForestGrass extends WorldGenerator +{ + private Block field_150522_a; + private int tallGrassMetadata; + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000437"; + + public WorldGenForestGrass(Block p_i45466_1_, int p_i45466_2_) + { + this.field_150522_a = p_i45466_1_; + this.tallGrassMetadata = p_i45466_2_; + } + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) + { + Block block; + + do + { + block = p_76484_1_.getBlock(p_76484_3_, p_76484_4_, p_76484_5_); + if (!(block.isLeaves(p_76484_1_, p_76484_3_, p_76484_4_, p_76484_5_) || block.isAir(p_76484_1_, p_76484_3_, p_76484_4_, p_76484_5_))) + { + break; + } + --p_76484_4_; + } while (p_76484_4_ > 0); + + for (int l = 0; l < 128; ++l) + { + int i1 = p_76484_3_ + p_76484_2_.nextInt(8) - p_76484_2_.nextInt(8); + int j1 = p_76484_4_ + p_76484_2_.nextInt(4) - p_76484_2_.nextInt(4); + int k1 = p_76484_5_ + p_76484_2_.nextInt(8) - p_76484_2_.nextInt(8); + + if (p_76484_1_.isAirBlock(i1, j1, k1) && this.field_150522_a.canBlockStay(p_76484_1_, i1, j1, k1)) + { + p_76484_1_.setBlock(i1, j1, k1, this.field_150522_a, this.tallGrassMetadata, 2); + } + } + + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestTrees.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestTrees.java new file mode 100644 index 0000000000..18791b0d15 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestTrees.java @@ -0,0 +1,252 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenForestTrees extends WorldGenForestAbstractTree +{ + /** The minimum height of a generated tree. */ + private final int minTreeHeight; + /** True if this tree should grow Vines. */ + private final boolean vinesGrow; + /** The wood to use in tree generation. */ + private static Block wood; + /** The leaves to use in tree generation. */ + private static Block leaves; + + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000438"; + + public WorldGenForestTrees(boolean p_i2027_1_) + { + this(p_i2027_1_, 6, leaves, wood, false); + } + + public WorldGenForestTrees(boolean p_i2028_1_, int minTreeHeight, Block metaWood, Block metaLeaves, boolean growVines) + { + super(p_i2028_1_); + this.minTreeHeight = minTreeHeight; + WorldGenForestTrees.wood = metaWood; + WorldGenForestTrees.leaves = metaLeaves; + this.vinesGrow = growVines; + } + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) + { + int l = p_76484_2_.nextInt(3) + this.minTreeHeight; + boolean flag = true; + + if (p_76484_4_ >= 1 && p_76484_4_ + l + 1 <= 256) + { + byte b0; + int k1; + Block block; + + for (int i1 = p_76484_4_; i1 <= p_76484_4_ + 1 + l; ++i1) + { + b0 = 1; + + if (i1 == p_76484_4_) + { + b0 = 0; + } + + if (i1 >= p_76484_4_ + 1 + l - 2) + { + b0 = 2; + } + + for (int j1 = p_76484_3_ - b0; j1 <= p_76484_3_ + b0 && flag; ++j1) + { + for (k1 = p_76484_5_ - b0; k1 <= p_76484_5_ + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + block = p_76484_1_.getBlock(j1, i1, k1); + + if (!this.isReplaceable(p_76484_1_, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block2 = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ - 1, p_76484_5_); + + boolean isSoil = block2.canSustainPlant(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && p_76484_4_ < 256 - l - 1) + { + block2.onPlantGrow(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, p_76484_3_, p_76484_4_, p_76484_5_); + b0 = 3; + byte b1 = 0; + int l1; + int i2; + int j2; + int i3; + + for (k1 = p_76484_4_ - b0 + l; k1 <= p_76484_4_ + l; ++k1) + { + i3 = k1 - (p_76484_4_ + l); + l1 = b1 + 1 - i3 / 2; + + for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2) + { + j2 = i2 - p_76484_3_; + + for (int k2 = p_76484_5_ - l1; k2 <= p_76484_5_ + l1; ++k2) + { + int l2 = k2 - p_76484_5_; + + if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || p_76484_2_.nextInt(2) != 0 && i3 != 0) + { + Block block1 = p_76484_1_.getBlock(i2, k1, k2); + + if (block1.isAir(p_76484_1_, i2, k1, k2) || block1.isLeaves(p_76484_1_, i2, k1, k2)) + { + this.setBlockAndNotifyAdequately(p_76484_1_, i2, k1, k2, Blocks.leaves, 0); + } + } + } + } + } + + for (k1 = 0; k1 < l; ++k1) + { + block = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_); + + if (block.isAir(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_) || block.isLeaves(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_)) + { + this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_, Blocks.log, 0); + +// if (this.vinesGrow && k1 > 0) +// { +// if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_)) +// { +// this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, 8); +// } +// +// if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_)) +// { +// this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, 2); +// } +// +// if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1)) +// { +// this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1, Blocks.vine, 1); +// } +// +// if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1)) +// { +// this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1, Blocks.vine, 4); +// } +// } + } + } + + if (this.vinesGrow) + { + for (k1 = p_76484_4_ - 3 + l; k1 <= p_76484_4_ + l; ++k1) + { + i3 = k1 - (p_76484_4_ + l); + l1 = 2 - i3 / 2; + + for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2) + { + for (j2 = p_76484_5_ - l1; j2 <= p_76484_5_ + l1; ++j2) + { +// if (p_76484_1_.getBlock(i2, k1, j2).isLeaves(p_76484_1_, i2, k1, j2)) +// { +// if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 - 1, k1, j2).isAir(p_76484_1_, i2 - 1, k1, j2)) +// { +// this.growVines(p_76484_1_, i2 - 1, k1, j2, 8); +// } +// +// if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 + 1, k1, j2).isAir(p_76484_1_, i2 + 1, k1, j2)) +// { +// this.growVines(p_76484_1_, i2 + 1, k1, j2, 2); +// } +// +// if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 - 1).isAir(p_76484_1_, i2, k1, j2 - 1)) +// { +// this.growVines(p_76484_1_, i2, k1, j2 - 1, 1); +// } +// +// if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 + 1).isAir(p_76484_1_, i2, k1, j2 + 1)) +// { +// this.growVines(p_76484_1_, i2, k1, j2 + 1, 4); +// } +// } + } + } + } + + if (p_76484_2_.nextInt(5) == 0 && l > 5) + { + for (k1 = 0; k1 < 2; ++k1) + { + for (i3 = 0; i3 < 4; ++i3) + { + if (p_76484_2_.nextInt(4 - k1) == 0) + { + l1 = p_76484_2_.nextInt(3); + this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + Direction.offsetX[Direction.rotateOpposite[i3]], p_76484_4_ + l - 5 + k1, p_76484_5_ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3); + } + } + } + } + } + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + /** + * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length + */ +// private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_) +// { +// this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); +// int i1 = 4; +// +// while (true) +// { +// --p_76529_3_; +// +// if (!p_76529_1_.getBlock(p_76529_2_, p_76529_3_, p_76529_4_).isAir(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_) || i1 <= 0) +// { +// return; +// } +// +// this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_); +// --i1; +// } +// } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenModMinable.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenModMinable.java new file mode 100644 index 0000000000..ef177493a1 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenModMinable.java @@ -0,0 +1,109 @@ +package gtPlusPlus.core.world.dimensionA.world.gen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class WorldGenModMinable extends WorldGenerator +{ + /** Block to replace */ + private Block field_150519_a; + + /** The number of blocks to generate. */ + private int numberOfBlocks; + + /** Ore to place in World */ + private Block field_150518_c; + + @SuppressWarnings("unused") + private static final String __OBFID = "CL_00000426"; + private int mineableBlockMeta; + + /** + * Generates Ores in World. + * @param blockToPlace + * @param howMeny + * @param replaceableBlock + */ + public WorldGenModMinable(Block blockToPlace, int howMeny, Block replaceableBlock) + { + this.field_150519_a = blockToPlace; + this.numberOfBlocks = howMeny; + this.field_150518_c = replaceableBlock; + } + + /** + * Generates Ores in World. + * @param block + * @param meta + * @param number + * @param target + */ + public WorldGenModMinable(Block block, int meta, int number, Block target) + { + this(block, number, target); + this.mineableBlockMeta = meta; + } + + /** + * Replaces Blocks with ores. + */ + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) + { + float f = p_76484_2_.nextFloat() * (float)Math.PI; + double d0 = p_76484_3_ + 8 + MathHelper.sin(f) * this.numberOfBlocks / 8.0F; + double d1 = p_76484_3_ + 8 - MathHelper.sin(f) * this.numberOfBlocks / 8.0F; + double d2 = p_76484_5_ + 8 + MathHelper.cos(f) * this.numberOfBlocks / 8.0F; + double d3 = p_76484_5_ + 8 - MathHelper.cos(f) * this.numberOfBlocks / 8.0F; + double d4 = p_76484_4_ + p_76484_2_.nextInt(3) - 2; + double d5 = p_76484_4_ + p_76484_2_.nextInt(3) - 2; + + for (int l = 0; l <= this.numberOfBlocks; ++l) + { + double d6 = d0 + (d1 - d0) * l / this.numberOfBlocks; + double d7 = d4 + (d5 - d4) * l / this.numberOfBlocks; + double d8 = d2 + (d3 - d2) * l / this.numberOfBlocks; + double d9 = p_76484_2_.nextDouble() * this.numberOfBlocks / 16.0D; + double d10 = (MathHelper.sin(l * (float)Math.PI / this.numberOfBlocks) + 1.0F) * d9 + 1.0D; + double d11 = (MathHelper.sin(l * (float)Math.PI / this.numberOfBlocks) + 1.0F) * d9 + 1.0D; + int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); + int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); + int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); + int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); + int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); + int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); + + for (int k2 = i1; k2 <= l1; ++k2) + { + double d12 = (k2 + 0.5D - d6) / (d10 / 2.0D); + + if (d12 * d12 < 1.0D) + { + for (int l2 = j1; l2 <= i2; ++l2) + { + double d13 = (l2 + 0.5D - d7) / (d11 / 2.0D); + + if (d12 * d12 + d13 * d13 < 1.0D) + { + for (int i3 = k1; i3 <= j2; ++i3) + { + double d14 = (i3 + 0.5D - d8) / (d10 / 2.0D); + + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && p_76484_1_.getBlock(k2, l2, i3).isReplaceableOreGen(p_76484_1_, k2, l2, i3, field_150518_c)) + { + p_76484_1_.setBlock(k2, l2, i3, this.field_150519_a, mineableBlockMeta, 2); + } + } + } + } + } + } + } + + return true; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayer.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayer.java new file mode 100644 index 0000000000..f27d710fae --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayer.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.world.dimensionA.world.genlayer; + +import net.minecraft.world.WorldType; +import net.minecraft.world.gen.layer.*; + +public class LightForestGenLayer extends GenLayer { + + public LightForestGenLayer(long seed) { + super(seed); + } + + public static GenLayer[] makeTheWorld(long seed, WorldType type) { + GenLayer biomes = new LightForestGenLayerBiomes(1L); + biomes = new GenLayerZoom(1000L, biomes); + biomes = new GenLayerZoom(1001L, biomes); + biomes = new GenLayerZoom(1002L, biomes); + biomes = new GenLayerZoom(1003L, biomes); + biomes = new GenLayerZoom(1004L, biomes); + biomes = new GenLayerZoom(1005L, biomes); + GenLayer genlayervoronoizoom = new GenLayerVoronoiZoom(10L, biomes); + biomes.initWorldGenSeed(seed); + genlayervoronoizoom.initWorldGenSeed(seed); + return new GenLayer[] { biomes, genlayervoronoizoom }; + } + + @Override + public int[] getInts(int p_75904_1_, int p_75904_2_, int p_75904_3_, int p_75904_4_) { + return null; + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayerBiomes.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayerBiomes.java new file mode 100644 index 0000000000..5e54fcb2ba --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayerBiomes.java @@ -0,0 +1,33 @@ +package gtPlusPlus.core.world.dimensionA.world.genlayer; + +import gtPlusPlus.core.world.dimensionA.world.biomes.ModBiomes; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; + +public class LightForestGenLayerBiomes extends GenLayer { + + // TODO: spawning with temperatures + protected BiomeGenBase[] allowedBiomes = { ModBiomes.forestLight, }; + + public LightForestGenLayerBiomes(long seed) { + super(seed); + } + + public LightForestGenLayerBiomes(long seed, GenLayer genlayer) { + super(seed); + this.parent = genlayer; + } + + @Override + public int[] getInts(int x, int z, int width, int depth) { + int[] dest = IntCache.getIntCache(width * depth); + for (int dz = 0; dz < depth; dz++) { + for (int dx = 0; dx < width; dx++) { + this.initChunkSeed(dx + x, dz + z); + dest[(dx + dz * width)] = this.allowedBiomes[nextInt(this.allowedBiomes.length)].biomeID; + } + } + return dest; + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/CloudRenderer.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/CloudRenderer.java new file mode 100644 index 0000000000..39d8a468b3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/CloudRenderer.java @@ -0,0 +1,13 @@ +package gtPlusPlus.core.world.dimensionA.world.renderers; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraftforge.client.IRenderHandler; + +public class CloudRenderer extends IRenderHandler { + + @Override + public void render(float partialTicks, WorldClient world, Minecraft mc) { + + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/SkyRenderer.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/SkyRenderer.java new file mode 100644 index 0000000000..69e3db720e --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/SkyRenderer.java @@ -0,0 +1,201 @@ +package gtPlusPlus.core.world.dimensionA.world.renderers; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.*; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.*; +import net.minecraft.util.*; +import net.minecraftforge.client.IRenderHandler; + +public class SkyRenderer extends IRenderHandler { + + private int starGLCallList; + private int glSkyList; + private int glSkyList2; + + public SkyRenderer() + { + RenderGlobal renderGlobal = Minecraft.getMinecraft().renderGlobal; + this.glSkyList2 = (this.glSkyList = (this.starGLCallList = ReflectionHelper.getPrivateValue(RenderGlobal.class, renderGlobal, "starGLCallList")) + 1) + 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void render(float partialTicks, WorldClient world, Minecraft mc) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); + float f1 = (float) vec3.xCoord; + float f2 = (float) vec3.yCoord; + float f3 = (float) vec3.zCoord; + float f4; + if (mc.gameSettings.anaglyph) + { + float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; + float f6 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; + f4 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; + f1 = f5; + f2 = f6; + f3 = f4; + } + GL11.glColor3f(f1, f2, f3); + Tessellator tessellator1 = Tessellator.instance; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_FOG); + GL11.glColor3f(f1, f2, f3); + GL11.glCallList(this.glSkyList); + 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(); + float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); + float f7; + float f8; + float f9; + float f10; + if (afloat != null) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glPushMatrix(); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + f4 = afloat[0]; + f7 = afloat[1]; + f8 = afloat[2]; + float f11; + if (mc.gameSettings.anaglyph) + { + f9 = (f4 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F; + f10 = (f4 * 30.0F + f7 * 70.0F) / 100.0F; + f11 = (f4 * 30.0F + f8 * 70.0F) / 100.0F; + f4 = f9; + f7 = f10; + f8 = f11; + } + tessellator1.startDrawing(6); + tessellator1.setColorRGBA_F(f4, f7, f8, afloat[3]); + tessellator1.addVertex(0.0D, 100.0D, 0.0D); + byte b0 = 16; + tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); + 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); + tessellator1.addVertex(f12 * 120.0F, f13 * 120.0F, -f13 * 40.0F * afloat[3]); + } + tessellator1.draw(); + GL11.glPopMatrix(); + GL11.glShadeModel(GL11.GL_FLAT); + } + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glPushMatrix(); + f4 = 1.0F - world.getRainStrength(partialTicks); + f7 = 0.0F; + f8 = 0.0F; + f9 = 0.0F; + GL11.glColor4f(1.0F, 1.0F, 1.0F, f4); + GL11.glTranslatef(f7, f8, f9); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); + + + f10 = 20.0F; // Size of sun from center + mc.renderEngine.getTexture(new ResourceLocation(CORE.MODID+":/textures/enviroment/sun.png")); + + + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((-f10), 100.0D, (-f10), 0.0D, 0.0D); + tessellator1.addVertexWithUV(f10, 100.0D, (-f10), 1.0D, 0.0D); + tessellator1.addVertexWithUV(f10, 100.0D, f10, 1.0D, 1.0D); + tessellator1.addVertexWithUV((-f10), 100.0D, f10, 0.0D, 1.0D); + + + tessellator1.draw(); // Draw sun + f10 = 15.0F; // Size of moon from center + mc.renderEngine.bindTexture(new ResourceLocation(CORE.MODID+":/textures/enviroment/moon_phases.png")); + + + int k = world.getMoonPhase(); + int l = k % 4; + int i1 = k / 4 % 2; + float f14 = (l + 0) / 4.0F; + float f15 = (i1 + 0) / 2.0F; + float f16 = (l + 1) / 4.0F; + float f17 = (i1 + 1) / 2.0F; + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((-f10), -100.0D, f10, f16, f17); + tessellator1.addVertexWithUV(f10, -100.0D, f10, f14, f17); + tessellator1.addVertexWithUV(f10, -100.0D, (-f10), f14, f15); + tessellator1.addVertexWithUV((-f10), -100.0D, (-f10), f16, f15); + tessellator1.draw(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + float f18 = world.getStarBrightness(partialTicks) * f4; + if (f18 > 0.0F) + { + GL11.glColor4f(f18, f18, f18, f18); + GL11.glCallList(this.starGLCallList); + } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor3f(0.0F, 0.0F, 0.0F); + double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon(); + if (d0 < 0.0D) + { + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 12.0F, 0.0F); + GL11.glCallList(this.glSkyList2); + GL11.glPopMatrix(); + f8 = 1.0F; + f9 = -((float) (d0 + 65.0D)); + f10 = -f8; + tessellator1.startDrawingQuads(); + tessellator1.setColorRGBA_I(0, 255); + tessellator1.addVertex((-f8), f9, f8); + tessellator1.addVertex(f8, f9, f8); + tessellator1.addVertex(f8, f10, f8); + tessellator1.addVertex((-f8), f10, f8); + tessellator1.addVertex((-f8), f10, (-f8)); + tessellator1.addVertex(f8, f10, (-f8)); + tessellator1.addVertex(f8, f9, (-f8)); + tessellator1.addVertex((-f8), f9, (-f8)); + tessellator1.addVertex(f8, f10, (-f8)); + tessellator1.addVertex(f8, f10, f8); + tessellator1.addVertex(f8, f9, f8); + tessellator1.addVertex(f8, f9, (-f8)); + tessellator1.addVertex((-f8), f9, (-f8)); + tessellator1.addVertex((-f8), f9, f8); + tessellator1.addVertex((-f8), f10, f8); + tessellator1.addVertex((-f8), f10, (-f8)); + tessellator1.addVertex((-f8), f10, (-f8)); + tessellator1.addVertex((-f8), f10, f8); + tessellator1.addVertex(f8, f10, f8); + tessellator1.addVertex(f8, f10, (-f8)); + tessellator1.draw(); + } + if (world.provider.isSkyColored()) + { + GL11.glColor3f(0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F); + } + else + { + GL11.glColor3f(f1, f2, f3); + } + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F); + GL11.glCallList(this.glSkyList2); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } +} diff --git a/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/WeatherRenderer.java b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/WeatherRenderer.java new file mode 100644 index 0000000000..ef64f9fbb8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/WeatherRenderer.java @@ -0,0 +1,227 @@ +package gtPlusPlus.core.world.dimensionA.world.renderers; + +import java.util.Random; + +import org.lwjgl.opengl.GL11; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.client.IRenderHandler; + +public class WeatherRenderer extends IRenderHandler { + + /** Rain X coords */ + float[] rainXCoords; + /** Rain Y coords */ + float[] rainYCoords; + +// EntityRenderer enitytRenderer; + Random rand = new Random(); + + private String weather_Name; + + private static final ResourceLocation locationRainPng = new ResourceLocation(CORE.MODID, "textures/environment/snow.png"); + + @Override + public void render(float partialTicks, WorldClient world, Minecraft mc) { + this.getWeatherToRenderer("fog"); + if(weather_Name != null){ + if(weather_Name == "fog"){ + // this.renderFog(partialTicks, world, mc, 50); + this.renderRainSnow(50, world, mc); + } + } + } + + public void getWeatherToRenderer(String weatherName){ + weather_Name = weatherName; + } + + protected void renderRainSnow(float par1, WorldClient world, Minecraft mc) + { +// IRenderHandler renderer = null; +// if ((renderer = mc.theWorld.provider.getWeatherRenderer()) != null) +// { +// renderer.render(par1, mc.theWorld, mc); +// return; +// } + + float f1 = mc.theWorld.getRainStrength(par1); + + if (f1 > 0.0F) + { +// enitytRenderer.enableLightmap((double)par1); + + if (this.rainXCoords == null) + { + this.rainXCoords = new float[1024]; + this.rainYCoords = new float[1024]; + + for (int i = 0; i < 32; ++i) + { + for (int j = 0; j < 32; ++j) + { + float f2 = j - 16; + float f3 = i - 16; + float f4 = MathHelper.sqrt_float(f2 * f2 + f3 * f3); + this.rainXCoords[i << 5 | j] = -f3 / f4; + this.rainYCoords[i << 5 | j] = f2 / f4; + } + } + } + + EntityLivingBase entitylivingbase = mc.renderViewEntity; + WorldClient worldclient = mc.theWorld; + int k2 = MathHelper.floor_double(entitylivingbase.posX); + int l2 = MathHelper.floor_double(entitylivingbase.posY); + int i3 = MathHelper.floor_double(entitylivingbase.posZ); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + double d0 = entitylivingbase.lastTickPosX + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * par1; + double d1 = entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * par1; + double d2 = entitylivingbase.lastTickPosZ + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * par1; + int k = MathHelper.floor_double(d1); + byte b0 = 5; + + if (mc.gameSettings.fancyGraphics) + { + b0 = 10; + } + + boolean flag = false; + byte b1 = -1; + float f5 = 312545411L + par1; + + if (mc.gameSettings.fancyGraphics) + { + b0 = 10; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + flag = false; + + for (int l = i3 - b0; l <= i3 + b0; ++l) + { + for (int i1 = k2 - b0; i1 <= k2 + b0; ++i1) + { + int j1 = (l - i3 + 16) * 32 + i1 - k2 + 16; + float f6 = this.rainXCoords[j1] * 0.5F; + float f7 = this.rainYCoords[j1] * 0.5F; + BiomeGenBase biomegenbase = worldclient.getBiomeGenForCoords(i1, l); + + if (biomegenbase.canSpawnLightningBolt() || biomegenbase.getEnableSnow()) + { + int k1 = worldclient.getPrecipitationHeight(i1, l); + int l1 = l2 - b0; + int i2 = l2 + b0; + + if (l1 < k1) + { + l1 = k1; + } + + if (i2 < k1) + { + i2 = k1; + } + + float f8 = 1.0F; + int j2 = k1; + + if (k1 < k) + { + j2 = k; + } + + if (l1 != i2) + { + rand.setSeed(i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761); + float f9 = biomegenbase.getFloatTemperature(i1, l1, l); + float f10; + double d4; + + if (worldclient.getWorldChunkManager().getTemperatureAtHeight(f9, k1) >= 0.15F) + { + if (b1 != 0) + { + if (b1 >= 0) + { + tessellator.draw(); + } + + b1 = 0; + mc.getTextureManager().bindTexture(locationRainPng); + tessellator.startDrawingQuads(); + } + + f10 = ((31542152L + i1 * i1 * 3121 + i1 * 45238971 + l * l * 418711 + l * 13761 & 31) + par1) / 32.0F * (3.0F + this.rand.nextFloat()); + double d3 = i1 + 0.5F - entitylivingbase.posX; + d4 = l + 0.5F - entitylivingbase.posZ; + float f12 = MathHelper.sqrt_double(d3 * d3 + d4 * d4) / b0; + float f13 = 1.0F; + tessellator.setBrightness(worldclient.getLightBrightnessForSkyBlocks(i1, j2, l, 0)); + tessellator.setColorRGBA_F(f13, f13, f13, ((1.0F - f12 * f12) * 0.5F + 0.5F) * f1); + tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); + tessellator.addVertexWithUV(i1 - f6 + 0.5D, l1, l - f7 + 0.5D, 0.0F * f8, l1 * f8 / 4.0F + f10 * f8); + tessellator.addVertexWithUV(i1 + f6 + 0.5D, l1, l + f7 + 0.5D, 1.0F * f8, l1 * f8 / 4.0F + f10 * f8); + tessellator.addVertexWithUV(i1 + f6 + 0.5D, i2, l + f7 + 0.5D, 1.0F * f8, i2 * f8 / 4.0F + f10 * f8); + tessellator.addVertexWithUV(i1 - f6 + 0.5D, i2, l - f7 + 0.5D, 0.0F * f8, i2 * f8 / 4.0F + f10 * f8); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + } +// else +// { +// if (b1 != 1) +// { +// if (b1 >= 0) +// { +// tessellator.draw(); +// } +// +// b1 = 1; +// mc.getTextureManager().bindTexture(locationSnowPng); +// tessellator.startDrawingQuads(); +// } +// +// f10 = ((float)(3584865L & 511) + par1) / 512.0F; +// float f16 = this.rand.nextFloat() + f5 * 0.01F * (float)this.rand.nextGaussian(); +// float f11 = this.rand.nextFloat() + f5 * (float)this.rand.nextGaussian() * 0.001F; +// d4 = (double)((float)i1 + 0.5F) - entitylivingbase.posX; +// double d5 = (double)((float)l + 0.5F) - entitylivingbase.posZ; +// float f14 = MathHelper.sqrt_double(d4 * d4 + d5 * d5) / (float)b0; +// float f15 = 1.0F; +// tessellator.setBrightness((worldclient.getLightBrightnessForSkyBlocks(i1, j2, l, 0) * 3 + 15728880) / 4); +// tessellator.setColorRGBA_F(f15, f15, f15, ((1.0F - f14 * f14) * 0.3F + 0.5F) * f1); +// tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); +// tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)l1, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11)); +// tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)l1, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11)); +// tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)i2, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11)); +// tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)i2, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11)); +// tessellator.setTranslation(0.0D, 0.0D, 0.0D); +// } + } + } + } + } + + if (b1 >= 0) + { + tessellator.draw(); + } + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + } + } +} |