Skip to content

Commit

Permalink
More vegetation stuff. Rewrote schematic loading slightly to properly…
Browse files Browse the repository at this point in the history
… handle loading files from within the jar.
  • Loading branch information
Deadrik committed Jul 24, 2015
1 parent 29874d9 commit bc5b3e0
Show file tree
Hide file tree
Showing 27 changed files with 177 additions and 84 deletions.
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gradlew.bat build
8 changes: 4 additions & 4 deletions src/API/com/bioxx/tfc2/api/Trees/TreeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.block.state.IBlockState;

import com.bioxx.tfc2.api.Types.Moisture;
import com.bioxx.tfc2.api.Types.Temp;
import com.bioxx.tfc2.api.Types.ClimateTemp;

public class TreeConfig
{
Expand All @@ -23,15 +23,15 @@ public class TreeConfig
/**
* Minimum Allowed Temperature
*/
public Temp minTemp;
public ClimateTemp minTemp;
/**
* Maximum Allowed Temperature
*/
public Temp maxTemp;
public ClimateTemp maxTemp;

public boolean isEvergreen;

public TreeConfig(String n, IBlockState w, IBlockState l, Moisture minR, Moisture maxR, Temp minT, Temp maxT, boolean eg)
public TreeConfig(String n, IBlockState w, IBlockState l, Moisture minR, Moisture maxR, ClimateTemp minT, ClimateTemp maxT, boolean eg)
{
name = n;
minMoisture = minR;
Expand Down
5 changes: 2 additions & 3 deletions src/API/com/bioxx/tfc2/api/Trees/TreeRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.Iterator;
import java.util.Random;

import com.bioxx.tfc2.api.Types.ClimateTemp;
import com.bioxx.tfc2.api.Types.Moisture;
import com.bioxx.tfc2.api.Types.Temp;

public class TreeRegistry
{
Expand All @@ -21,7 +21,6 @@ public TreeRegistry()

public void RegisterSchematic(TreeSchematic treeSchematic, String name)
{

if(!treeList.containsKey(name))
treeList.put(name, new TreeSchemManager());

Expand Down Expand Up @@ -97,7 +96,7 @@ public TreeConfig getRandomTree()
return treeTypeHash.get(treeTypeHash.keySet().toArray(new String[treeTypeHash.keySet().size()])[id]);
}

public String getRandomTreeTypeForIsland(Random r, Temp temp, Moisture moisture)
public String getRandomTreeTypeForIsland(Random r, ClimateTemp temp, Moisture moisture)
{
ArrayList<String> list = new ArrayList<String>();
Iterator iter = treeTypeHash.keySet().iterator();
Expand Down
27 changes: 15 additions & 12 deletions src/API/com/bioxx/tfc2/api/Trees/TreeSchematic.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ public class TreeSchematic extends Schematic
{
private int size;

public TreeSchematic(String p)
public TreeSchematic(String p, String f)
{
super(p);
super(p, f);
}

@Override
public boolean Load()
{
super.Load();
int num = path.indexOf('-');
String s = path.substring(0, num);
if(s.equals("Large"))
size = 2;
else if(s.equals("Normal"))
size = 1;
else
size = 0;
return true;
if(super.Load())
{
int num = filename.indexOf('_');
String s = filename.substring(0, num);
if(s.equals("Large"))
size = 2;
else if(s.equals("Normal"))
size = 1;
else
size = 0;
return true;
}
return false;
}

public int getGrowthStage()
Expand Down
19 changes: 19 additions & 0 deletions src/API/com/bioxx/tfc2/api/Types/ClimateTemp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.bioxx.tfc2.api.Types;


public enum ClimateTemp
{
POLAR(0), SUBPOLAR(0.25), TEMPERATE(0.5), SUBTROPICAL(0.75), TROPICAL(1);

double temp;

ClimateTemp(double d)
{
temp = d;
}

public double getTemp()
{
return temp;
}
}
2 changes: 1 addition & 1 deletion src/API/com/bioxx/tfc2/api/Types/Temp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public enum Temp
{
POLAR(0), SUBPOLAR(0.25), TEMPERATE(0.5), SUBTROPICAL(0.75), TROPICAL(1);
FRIGID(0), COLD(0.16), COOL(0.33), TEMPERATE(0.5), WARM(0.66), HOT(0.83), SCORCHING(1);

double temp;

Expand Down
10 changes: 5 additions & 5 deletions src/Common/com/bioxx/jMapGen/IslandParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.bioxx.libnoise.module.source.Perlin;
import com.bioxx.tfc2.api.Types.Moisture;
import com.bioxx.tfc2.api.Types.StoneType;
import com.bioxx.tfc2.api.Types.Temp;
import com.bioxx.tfc2.api.Types.ClimateTemp;
import com.bioxx.tfc2.api.Types.WoodType;

public class IslandParameters
Expand Down Expand Up @@ -42,7 +42,7 @@ public class IslandParameters
private String treeUncommon = WoodType.Ash.getName();
private String treeRare = WoodType.Ash.getName();
private Moisture moisture = Moisture.MEDIUM;
private Temp temp = Temp.TEMPERATE;
private ClimateTemp temp = ClimateTemp.TEMPERATE;

public IslandParameters()
{
Expand Down Expand Up @@ -182,12 +182,12 @@ public Moisture getIslandMoisture()
return moisture;
}

public Temp getIslandTemp()
public ClimateTemp getIslandTemp()
{
return temp;
}

public void setIslandTemp(Temp t)
public void setIslandTemp(ClimateTemp t)
{
temp = t;
}
Expand All @@ -214,7 +214,7 @@ public void readFromNBT(NBTTagCompound nbt)
this.treeUncommon = nbt.getString("treeUncommon");
this.treeRare = nbt.getString("treeRare");
this.moisture = Moisture.values()[nbt.getInteger("moisture")];
this.temp = Temp.values()[nbt.getInteger("temp")];
this.temp = ClimateTemp.values()[nbt.getInteger("temp")];
}

public void writeToNBT(NBTTagCompound nbt)
Expand Down
10 changes: 9 additions & 1 deletion src/Common/com/bioxx/tfc2/Blocks/BlockLeaves.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.bioxx.jMapGen.Map;
import com.bioxx.jMapGen.Point;
import com.bioxx.tfc2.TFCBlocks;
import com.bioxx.tfc2.World.WorldGen;
import com.bioxx.tfc2.api.Types.WoodType;

public class BlockLeaves extends BlockTerra
Expand Down Expand Up @@ -56,7 +59,12 @@ public int getBlockColor()
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return worldIn.getBiomeGenForCoords(pos).func_180625_c(pos);
int x = pos.getX() >> 12;
int z = pos.getZ() >> 12;
Map m = WorldGen.instance.getIslandMap(x, z);
double d0 = m.islandParams.getIslandTemp().getTemp();
double d1 = m.getSelectedHexagon(new Point(pos.getX(), pos.getZ())).moisture;
return ColorizerGrass.getGrassColor(d0, d1);
}

@Override
Expand Down
10 changes: 9 additions & 1 deletion src/Common/com/bioxx/tfc2/Blocks/BlockVegetation.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.bioxx.jMapGen.Map;
import com.bioxx.jMapGen.Point;
import com.bioxx.tfc2.TFCBlocks;
import com.bioxx.tfc2.World.WorldGen;

public class BlockVegetation extends BlockTerra
{
Expand Down Expand Up @@ -87,7 +90,12 @@ public int getBlockColor()
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return worldIn.getBiomeGenForCoords(pos).func_180627_b(pos);
int x = pos.getX() >> 12;
int z = pos.getZ() >> 12;
Map m = WorldGen.instance.getIslandMap(x, z);
double d0 = m.islandParams.getIslandTemp().getTemp();
double d1 = m.getSelectedHexagon(new Point(pos.getX(), pos.getZ())).moisture;
return ColorizerGrass.getGrassColor(d0, d1);
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions src/Common/com/bioxx/tfc2/Blocks/Terrain/BlockGrass.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.bioxx.jMapGen.Map;
import com.bioxx.jMapGen.Point;
import com.bioxx.tfc2.TFCBlocks;
import com.bioxx.tfc2.Blocks.BlockTerra;
import com.bioxx.tfc2.World.WorldGen;
import com.bioxx.tfc2.api.Types.StoneType;

public class BlockGrass extends BlockTerra
Expand Down Expand Up @@ -96,7 +98,13 @@ public int getBlockColor()
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return BiomeColorHelper.func_180286_a(worldIn, pos);
int x = pos.getX() >> 12;
int z = pos.getZ() >> 12;
Map m = WorldGen.instance.getIslandMap(x, z);
double d0 = m.islandParams.getIslandTemp().getTemp();
double d1 = m.getSelectedHexagon(new Point(pos.getX(), pos.getZ())).moisture;
return ColorizerGrass.getGrassColor(d0, d1);
//return ColorizerGrass.getGrassColor(0.5, 1);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/Common/com/bioxx/tfc2/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static Block getGroundAboveSeaLevel(World world, BlockPos pos)
{
BlockPos blockpos1;

for (blockpos1 = new BlockPos(pos.getX(), 32, pos.getZ()); !world.isAirBlock(blockpos1.offsetUp()); blockpos1 = blockpos1.offsetUp())
for (blockpos1 = new BlockPos(pos.getX(), 63, pos.getZ()); !world.isAirBlock(blockpos1.offsetUp()); blockpos1 = blockpos1.offsetUp())
{
;
}
Expand Down
15 changes: 10 additions & 5 deletions src/Common/com/bioxx/tfc2/CoreStuff/Schematic.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

import com.bioxx.tfc2.TFC;
import com.bioxx.tfc2.api.Interfaces.ISchematic;

public class Schematic implements ISchematic
Expand All @@ -23,11 +22,13 @@ public class Schematic implements ISchematic
protected NBTTagList te;
protected NBTTagList entities;
protected String path;
protected String filename;
protected int id;

public Schematic(String p)
public Schematic(String p, String f)
{
path = p;
filename = f;
}

@Override
Expand All @@ -36,7 +37,9 @@ public boolean Load()
NBTTagCompound tree;
try
{
InputStream fis = TFC.instance.getClass().getClassLoader().getResourceAsStream(path);
InputStream fis = getClass().getResourceAsStream(path);
if(fis == null)
return false;
tree = CompressedStreamTools.readCompressed(fis);
height = tree.getShort("Height");
width = tree.getShort("Width");
Expand Down Expand Up @@ -70,11 +73,13 @@ else if(tree.hasKey("BlocksInt"))
}
catch (FileNotFoundException e)
{
System.out.println("TFC FileNotFound: " + path); return false;
//System.out.println("TFC FileNotFound: " + path);
return false;
}
catch (IOException e)
{
System.out.println("TFC IOException: " + path); return false;
//System.out.println("TFC IOException: " + path);
return false;
}
return true;
}
Expand Down
Loading

0 comments on commit bc5b3e0

Please sign in to comment.