Skip to content

Commit

Permalink
optimize worldGen & LeavesRender
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzuanpa committed Mar 9, 2024
1 parent 7a6fc2e commit 20ea231
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/Common/com/bioxx/tfc/Blocks/Terrain/BlockFungi.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean canBlockStay(World world, int x, int y, int z)
if (y >= 0 && y < 256)
{
Block var5 = world.getBlock(x, y - 1, z);
return var5 == Blocks.mycelium || world.getFullBlockLightValue(x, y, z) < 13 && this.canThisPlantGrowOnThisBlock(var5);
return var5 == Blocks.mycelium || !world.canBlockSeeTheSky(x,y,z) && this.canThisPlantGrowOnThisBlock(var5);
}
else
{
Expand Down
23 changes: 1 addition & 22 deletions src/Common/com/bioxx/tfc/Blocks/Vanilla/BlockCustomLeaves.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,7 @@ public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e
entity.motionZ *= 0.1D;
}

@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
{
Block block = world.getBlock(x, y, z);
/*if(!Minecraft.isFancyGraphicsEnabled() && block == this)
return false;*/
if (side == 0 && this.minY > 0.0D)
return true;
else if (side == 1 && this.maxY < 1.0D)
return true;
else if (side == 2 && this.minZ > 0.0D)
return true;
else if (side == 3 && this.maxZ < 1.0D)
return true;
else if (side == 4 && this.minX > 0.0D)
return true;
else if (side == 5 && this.maxX < 1.0D)
return true;
else
return !block.isOpaqueCube();
}


@Override
public void updateTick(World world, int x, int y, int z, Random rand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ protected boolean canThisPlantGrowOnThisBlock(Block block)
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
return (world.getFullBlockLightValue(x, y, z) >= 8 ||
world.canBlockSeeTheSky(x, y, z)) &&
return (world.canBlockSeeTheSky(x, y, z)) &&
this.canThisPlantGrowOnThisBlock(world.getBlock(x, y - 1, z));
}

Expand Down
5 changes: 1 addition & 4 deletions src/Common/com/bioxx/tfc/Render/TESR/TESRWorldItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public void renderAt(TEWorldItem te, double d, double d1, double d2, float f)
this.bindTexture(TextureMap.locationItemsTexture);
}

boolean fancy = RenderManager.instance.options.fancyGraphics;
//RenderManager.instance.options.fancyGraphics = true;
GL11.glPushMatrix(); //start
GL11.glPushMatrix();

if(RenderManager.instance.options.fancyGraphics)
{
Expand All @@ -80,7 +78,6 @@ public void renderAt(TEWorldItem te, double d, double d1, double d2, float f)
tessellator.draw();
}
GL11.glPopMatrix(); //end
RenderManager.instance.options.fancyGraphics = fancy;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public WorldGenAcaciaKoaTrees(boolean par1, int id)
{
super(par1);
treeId = id;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,36 @@ public WorldGenLooseRocks()

public boolean generateRocks(World world, Random random, int i, int j, int k)
{
if ((world.isAirBlock(i, j + 1, k) || world.getBlock(i, j + 1, k) == Blocks.snow || world.getBlock(i, j + 1, k) == TFCBlocks.tallGrass) &&
(world.getBlock(i, j, k).getMaterial() == Material.grass || world.getBlock(i, j, k).getMaterial() == Material.rock) && world.getBlock(i, j, k).isOpaqueCube())
if (!((world.isAirBlock(i, j + 1, k) || world.getBlock(i, j + 1, k) == Blocks.snow || world.getBlock(i, j + 1, k) == TFCBlocks.tallGrass) &&
(world.getBlock(i, j, k).getMaterial() == Material.grass || world.getBlock(i, j, k).getMaterial() == Material.rock) && world.getBlock(i, j, k).isOpaqueCube()))return false;


if(world.setBlock(i, j+1, k, TFCBlocks.worldItem, 0, 2))
{
if(world.setBlock(i, j+1, k, TFCBlocks.worldItem, 0, 2))
TEWorldItem te =(TEWorldItem)world.getTileEntity(i, j + 1, k);
ItemStack sample = getCoreSample(world, i, j, k);
if(world.rand.nextInt(3) == 0 && sample != null)
{
TEWorldItem te =(TEWorldItem)world.getTileEntity(i, j + 1, k);
ItemStack sample = getCoreSample(world, i, j, k);
if(world.rand.nextInt(3) == 0 && sample != null)
{
te.storage[0] = sample;
}
else
{
DataLayer dl = TFC_Climate.getRockLayer(world, i, j, k, 0);
//BlockMeta rockLayer = new BlockMeta(dl.block, dl.data2);
te.storage[0] = new ItemStack(TFCItems.looseRock, 1, dl.data1);
}
te.storage[0] = sample;
}
}
else
{
DataLayer dl = TFC_Climate.getRockLayer(world, i, j, k, 0);
//BlockMeta rockLayer = new BlockMeta(dl.block, dl.data2);
te.storage[0] = new ItemStack(TFCItems.looseRock, 1, dl.data1);
} }

return true;
}

private ItemStack getCoreSample(World world, int xCoord, int yCoord, int zCoord)
{
ArrayList<Item> coreSample = new ArrayList<Item>();
ArrayList<ItemStack> coreSampleStacks = new ArrayList<ItemStack>();
for (int x = -15; x < 16; x++)
for (int x = -15; x < 16; x+=2)
{
for (int z = -15; z < 16; z++)
for (int z = -15; z < 16; z+=2)
{
for(int y = yCoord; y > yCoord-35; y--)
for(int y = yCoord-4; y > yCoord-35; y-=2)
{
// Metal
if (world.blockExists(xCoord + x, y, zCoord + z) && world.getBlock(xCoord + x, y, zCoord + z) == TFCBlocks.ore)
Expand Down Expand Up @@ -108,8 +107,8 @@ private ItemStack getCoreSample(World world, int xCoord, int yCoord, int zCoord)

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{ if(!(world.provider instanceof TFCProvider))return;
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
if(!(world.provider instanceof TFCProvider))return;

chunkX *= 16;
chunkZ *= 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class WorldGenMinable extends WorldGenerator
//private int mineGen = 1;
//private int subMineGen = 1;
private final int rarity;
private final int veinSi;
private final int veinSize;
private final int veinAm;
private final int height;
private int mineHeight = 2;
Expand All @@ -76,7 +76,7 @@ public WorldGenMinable(Block block, int j, Block layerBlock, int layerMeta, int
this.genInBlock = layerBlock;
this.genInBlockMeta = layerMeta;
this.rarity = rarity;
this.veinSi = veinSize;
this.veinSize = veinSize;
this.veinAm = veinAmount;
this.height = height;
this.diameter = diameter;
Expand Down Expand Up @@ -106,9 +106,9 @@ private void createMine(World worldObj, Random rand, int x, int z)
int posY = temp2;
int posZ = z + temp3;
if (!useMarcoVeins)
bODgenerate(worldObj, rand, posX, posY, posZ, veinSi); // generate based on values
bODgenerate(worldObj, rand, posX, posY, posZ, veinSize); // generate based on values
else
bODgenerateVein(worldObj, rand, posX, posY, posZ, veinSi);
bODgenerateVein(worldObj, rand, posX, posY, posZ, veinSize);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Common/com/bioxx/tfc/WorldGen/Generators/WorldGenOre.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void oreMediumVein(Block block, int meta, Map<Block, List<Integer>> base
private void oreLargeVein(Block block, int meta, Map<Block, List<Integer>> baseRocks, int rarity, int min, int max, int vDensity, int hDensity)
{
createOreVein(block, meta ,baseRocks,
/*rarity*/rarity,/*veinSize*/60,/*veinAmt*/45,/*height*/20,/*diameter*/80,/*vDensity*/vDensity,/*hDensity*/hDensity,
/*rarity*/rarity,/*veinSize*/45,/*veinAmt*/45,/*height*/20,/*diameter*/80,/*vDensity*/vDensity,/*hDensity*/hDensity,
worldObj, random, chunkX, chunkZ, min, max);
}

Expand All @@ -99,14 +99,14 @@ private void oreSmall(Block block, int meta, Map<Block, List<Integer>> baseRocks
private void oreMedium(Block block, int meta, Map<Block, List<Integer>> baseRocks, int rarity, int min, int max, int vDensity, int hDensity)
{
createOre(block, meta ,baseRocks,
/*rarity*/rarity,/*veinSize*/30,/*veinAmt*/40,/*height*/10,/*diameter*/120,/*vDensity*/vDensity,/*hDensity*/hDensity,
/*rarity*/rarity,/*veinSize*/25,/*veinAmt*/40,/*height*/10,/*diameter*/120,/*vDensity*/vDensity,/*hDensity*/hDensity,
worldObj, random, chunkX, chunkZ, min, max);
}

private void oreLarge(Block block, int meta, Map<Block, List<Integer>> baseRocks, int rarity, int min, int max, int vDensity, int hDensity)
{
createOre(block, meta ,baseRocks,
/*rarity*/rarity,/*veinSize*/60,/*veinAmt*/40,/*height*/5,/*diameter*/120,/*vDensity*/vDensity,/*hDensity*/hDensity,
/*rarity*/rarity,/*veinSize*/45,/*veinAmt*/40,/*height*/5,/*diameter*/120,/*vDensity*/vDensity,/*hDensity*/hDensity,
worldObj, random, chunkX, chunkZ, min, max);
}

Expand Down

0 comments on commit 20ea231

Please sign in to comment.