From 0ce12b7874ff31d6fabc6c6f7402e00f7b0f34c1 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 30 Apr 2017 21:40:30 +1000 Subject: + Added the base work for a new dimension. --- src/Java/gtPlusPlus/core/world/DimensionIDs.java | 7 + .../core/world/dimensionA/block/BlockModBush.java | 156 ++++++ .../world/dimensionA/block/BlockModPortal.java | 455 ++++++++++++++++++ .../world/dimensionA/particle/EntityTreeFX.java | 103 ++++ .../dimensionA/util/Dimension_A_Teleporter.java | 531 +++++++++++++++++++++ .../core/world/dimensionA/util/Names.java | 10 + .../core/world/dimensionA/util/ReadFile.java | 91 ++++ .../dimensionA/world/ChunkProviderForest.java | 489 +++++++++++++++++++ .../core/world/dimensionA/world/Dimension.java | 22 + .../dimensionA/world/WorldChunkManagerForest.java | 288 +++++++++++ .../dimensionA/world/WorldProviderForest.java | 217 +++++++++ .../world/dimensionA/world/WorldTypesTutorial.java | 59 +++ .../dimensionA/world/biomes/BiomeDarkForest.java | 35 ++ .../world/dimensionA/world/biomes/BiomeIDs.java | 8 + .../dimensionA/world/biomes/BiomeLightForest.java | 47 ++ .../world/dimensionA/world/biomes/ModBiomes.java | 165 +++++++ .../biomes/decorators/BiomeDecoratorHelper.java | 105 ++++ .../world/biomes/decorators/BiomeDecoratorMod.java | 73 +++ .../dimensionA/world/gen/WorldGenEffectTree.java | 212 ++++++++ .../world/gen/WorldGenForestAbstractTree.java | 33 ++ .../world/gen/WorldGenForestBigTree.java | 526 ++++++++++++++++++++ .../dimensionA/world/gen/WorldGenForestGrass.java | 51 ++ .../dimensionA/world/gen/WorldGenForestTrees.java | 252 ++++++++++ .../dimensionA/world/gen/WorldGenModMinable.java | 109 +++++ .../world/genlayer/LightForestGenLayer.java | 30 ++ .../world/genlayer/LightForestGenLayerBiomes.java | 33 ++ .../dimensionA/world/renderers/CloudRenderer.java | 13 + .../dimensionA/world/renderers/SkyRenderer.java | 201 ++++++++ .../world/renderers/WeatherRenderer.java | 227 +++++++++ 29 files changed, 4548 insertions(+) create mode 100644 src/Java/gtPlusPlus/core/world/DimensionIDs.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModBush.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/block/BlockModPortal.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/particle/EntityTreeFX.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/util/Dimension_A_Teleporter.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/util/Names.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/util/ReadFile.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/ChunkProviderForest.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/Dimension.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/WorldChunkManagerForest.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/WorldProviderForest.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/WorldTypesTutorial.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeDarkForest.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeIDs.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/BiomeLightForest.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/ModBiomes.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorHelper.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/biomes/decorators/BiomeDecoratorMod.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenEffectTree.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestAbstractTree.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestBigTree.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestGrass.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenForestTrees.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/gen/WorldGenModMinable.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayer.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/genlayer/LightForestGenLayerBiomes.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/CloudRenderer.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/SkyRenderer.java create mode 100644 src/Java/gtPlusPlus/core/world/dimensionA/world/renderers/WeatherRenderer.java (limited to 'src/Java/gtPlusPlus/core/world') 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 biomegenbas