Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added tallgrass that changes texture based on rain/temp values
should be able to use the same technique for "seasonal" flower textures
  • Loading branch information
Konlii committed Feb 22, 2019
1 parent a49fe15 commit 5d81fca
Show file tree
Hide file tree
Showing 62 changed files with 942 additions and 195 deletions.
Expand Up @@ -29,8 +29,8 @@ public class TFCRegistries
public static final IForgeRegistry<KnappingRecipe> KNAPPING = GameRegistry.findRegistry(KnappingRecipe.class);

public static final IForgeRegistry<Plant> PLANTS = GameRegistry.findRegistry(Plant.class);
public static final IForgeRegistry<DoublePlant> DOUBLEPLANTS = GameRegistry.findRegistry(DoublePlant.class);
public static final IForgeRegistry<CreepingPlant> CREEPINGPLANTS = GameRegistry.findRegistry(CreepingPlant.class);
public static final IForgeRegistry<DoublePlant> DOUBLE_PLANTS = GameRegistry.findRegistry(DoublePlant.class);
public static final IForgeRegistry<CreepingPlant> CREEPING_PLANTS = GameRegistry.findRegistry(CreepingPlant.class);

static
{
Expand Down
Expand Up @@ -20,8 +20,8 @@ public final class TFCRegistryNames
public static final ResourceLocation TREE = new ResourceLocation(MOD_ID, "tree");
public static final ResourceLocation METAL = new ResourceLocation(MOD_ID, "metal");
public static final ResourceLocation PLANT = new ResourceLocation(MOD_ID, "plant");
public static final ResourceLocation DOUBLEPLANT = new ResourceLocation(MOD_ID, "double_plant");
public static final ResourceLocation CREEPINGPLANT = new ResourceLocation(MOD_ID, "creeping_plant");
public static final ResourceLocation DOUBLE_PLANT = new ResourceLocation(MOD_ID, "double_plant");
public static final ResourceLocation CREEPING_PLANT = new ResourceLocation(MOD_ID, "creeping_plant");

public static final ResourceLocation ALLOY_RECIPE = new ResourceLocation(MOD_ID, "alloy_recipe");
public static final ResourceLocation KNAPPING_RECIPE = new ResourceLocation(MOD_ID, "knapping_recipe");
Expand Down
49 changes: 8 additions & 41 deletions src/main/java/net/dries007/tfc/api/types/CreepingPlant.java
Expand Up @@ -14,13 +14,10 @@

public class CreepingPlant extends IForgeRegistryEntry.Impl<CreepingPlant>
{
private final float dominance;
private final float minTemp;
private final float maxTemp;
private final float minRain;
private final float maxRain;
private final float minDensity;
private final float maxDensity;

/**
* Addon mods that want to add flowers should subscribe to the registry event for this class
Expand All @@ -29,36 +26,25 @@ public class CreepingPlant extends IForgeRegistryEntry.Impl<CreepingPlant>
* When using this class, use the provided Builder to create your flowers. This will require all the default values, as well as
* provide optional values that you can change
*
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
* @param minDensity min density. Use -1 to get all density values. 0.1 is the default, to create really low density regions of no flowers
* @param maxDensity max density. Use 2 to get all density values
* @param dominance how much this flower is chosen over other flowers. Range 0 <> 10 with 10 being the most common
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
*/
public CreepingPlant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain, float minDensity, float maxDensity, float dominance)
public CreepingPlant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain)
{
this.minTemp = minTemp;
this.maxTemp = maxTemp;
this.minRain = minRain;
this.maxRain = maxRain;
this.dominance = dominance;
this.minDensity = minDensity;
this.maxDensity = maxDensity;

setRegistryName(name);
}

public boolean isValidLocation(float temp, float rain, float density)
{
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain && minDensity <= density && maxDensity >= density;
}

public float getDominance()
{
return dominance;
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain;
}

@Override
Expand All @@ -73,9 +59,6 @@ public static class Builder
private float maxTemp;
private float minRain;
private float maxRain;
private float minDensity;
private float maxDensity;
private float dominance;
private ResourceLocation name;

public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, float minTemp, float maxTemp)
Expand All @@ -85,27 +68,11 @@ public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, flo
this.minRain = minRain;
this.maxRain = maxRain;
this.name = name;
this.dominance = 0.001f * (maxTemp - minTemp) * (maxRain - minRain);
this.minDensity = 0.1f;
this.maxDensity = 2f;
}

public CreepingPlant.Builder setDensity(float min, float max)
{
this.minDensity = min;
this.maxDensity = max;
return this;
}

public CreepingPlant.Builder setDominance(float dom)
{
this.dominance = dom;
return this;
}

public CreepingPlant build()
{
return new CreepingPlant(name, minTemp, maxTemp, minRain, maxRain, minDensity, maxDensity, dominance);
return new CreepingPlant(name, minTemp, maxTemp, minRain, maxRain);
}
}
}
51 changes: 9 additions & 42 deletions src/main/java/net/dries007/tfc/api/types/DoublePlant.java
Expand Up @@ -14,13 +14,10 @@

public class DoublePlant extends IForgeRegistryEntry.Impl<DoublePlant>
{
private final float dominance;
private final float minTemp;
private final float maxTemp;
private final float minRain;
private final float maxRain;
private final float minDensity;
private final float maxDensity;

/**
* Addon mods that want to add flowers should subscribe to the registry event for this class
Expand All @@ -29,36 +26,25 @@ public class DoublePlant extends IForgeRegistryEntry.Impl<DoublePlant>
* When using this class, use the provided Builder to create your flowers. This will require all the default values, as well as
* provide optional values that you can change
*
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
* @param minDensity min density. Use -1 to get all density values. 0.1 is the default, to create really low density regions of no flowers
* @param maxDensity max density. Use 2 to get all density values
* @param dominance how much this flower is chosen over other flowers. Range 0 <> 10 with 10 being the most common
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
*/
public DoublePlant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain, float minDensity, float maxDensity, float dominance)
public DoublePlant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain)
{
this.minTemp = minTemp;
this.maxTemp = maxTemp;
this.minRain = minRain;
this.maxRain = maxRain;
this.dominance = dominance;
this.minDensity = minDensity;
this.maxDensity = maxDensity;

setRegistryName(name);
}

public boolean isValidLocation(float temp, float rain, float density)
public boolean isValidLocation(float temp, float rain)
{
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain && minDensity <= density && maxDensity >= density;
}

public float getDominance()
{
return dominance;
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain;
}

@Override
Expand All @@ -73,9 +59,6 @@ public static class Builder
private float maxTemp;
private float minRain;
private float maxRain;
private float minDensity;
private float maxDensity;
private float dominance;
private ResourceLocation name;

public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, float minTemp, float maxTemp)
Expand All @@ -85,27 +68,11 @@ public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, flo
this.minRain = minRain;
this.maxRain = maxRain;
this.name = name;
this.dominance = 0.001f * (maxTemp - minTemp) * (maxRain - minRain);
this.minDensity = 0.1f;
this.maxDensity = 2f;
}

public DoublePlant.Builder setDensity(float min, float max)
{
this.minDensity = min;
this.maxDensity = max;
return this;
}

public DoublePlant.Builder setDominance(float dom)
{
this.dominance = dom;
return this;
}

public DoublePlant build()
{
return new DoublePlant(name, minTemp, maxTemp, minRain, maxRain, minDensity, maxDensity, dominance);
return new DoublePlant(name, minTemp, maxTemp, minRain, maxRain);
}
}
}
51 changes: 9 additions & 42 deletions src/main/java/net/dries007/tfc/api/types/Plant.java
Expand Up @@ -14,13 +14,10 @@

public class Plant extends IForgeRegistryEntry.Impl<Plant>
{
private final float dominance;
private final float minTemp;
private final float maxTemp;
private final float minRain;
private final float maxRain;
private final float minDensity;
private final float maxDensity;

/**
* Addon mods that want to add flowers should subscribe to the registry event for this class
Expand All @@ -29,36 +26,25 @@ public class Plant extends IForgeRegistryEntry.Impl<Plant>
* When using this class, use the provided Builder to create your flowers. This will require all the default values, as well as
* provide optional values that you can change
*
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
* @param minDensity min density. Use -1 to get all density values. 0.1 is the default, to create really low density regions of no flowers
* @param maxDensity max density. Use 2 to get all density values
* @param dominance how much this flower is chosen over other flowers. Range 0 <> 10 with 10 being the most common
* @param name the ResourceLocation registry name of this flower
* @param minTemp min temperature
* @param maxTemp max temperature
* @param minRain min rainfall
* @param maxRain max rainfall
*/
public Plant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain, float minDensity, float maxDensity, float dominance)
public Plant(@Nonnull ResourceLocation name, float minTemp, float maxTemp, float minRain, float maxRain)
{
this.minTemp = minTemp;
this.maxTemp = maxTemp;
this.minRain = minRain;
this.maxRain = maxRain;
this.dominance = dominance;
this.minDensity = minDensity;
this.maxDensity = maxDensity;

setRegistryName(name);
}

public boolean isValidLocation(float temp, float rain, float density)
public boolean isValidLocation(float temp, float rain)
{
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain && minDensity <= density && maxDensity >= density;
}

public float getDominance()
{
return dominance;
return minTemp <= temp && maxTemp >= temp && minRain <= rain && maxRain >= rain;
}

@Override
Expand All @@ -73,9 +59,6 @@ public static class Builder
private float maxTemp;
private float minRain;
private float maxRain;
private float minDensity;
private float maxDensity;
private float dominance;
private ResourceLocation name;

public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, float minTemp, float maxTemp)
Expand All @@ -85,27 +68,11 @@ public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, flo
this.minRain = minRain;
this.maxRain = maxRain;
this.name = name;
this.dominance = 0.001f * (maxTemp - minTemp) * (maxRain - minRain);
this.minDensity = 0.1f;
this.maxDensity = 2f;
}

public Plant.Builder setDensity(float min, float max)
{
this.minDensity = min;
this.maxDensity = max;
return this;
}

public Plant.Builder setDominance(float dom)
{
this.dominance = dom;
return this;
}

public Plant build()
{
return new Plant(name, minTemp, maxTemp, minRain, maxRain, minDensity, maxDensity, dominance);
return new Plant(name, minTemp, maxTemp, minRain, maxRain);
}
}
}
34 changes: 34 additions & 0 deletions src/main/java/net/dries007/tfc/client/ClientRegisterEvents.java
Expand Up @@ -47,6 +47,8 @@
import net.dries007.tfc.objects.Gem;
import net.dries007.tfc.objects.blocks.BlockSlabTFC;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.plants.BlockDoublePlantTFC;
import net.dries007.tfc.objects.blocks.plants.BlockPlantTFC;
import net.dries007.tfc.objects.blocks.stone.BlockFarmlandTFC;
import net.dries007.tfc.objects.blocks.stone.BlockOreTFC;
import net.dries007.tfc.objects.blocks.stone.BlockRockVariant;
Expand Down Expand Up @@ -223,6 +225,22 @@ public static void registerColorHandlerBlocks(ColorHandlerEvent.Block event)
blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(),
BlocksTFC.getAllLeafBlocks().toArray(new Block[0]));

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D),
BlocksTFC.TALL_GRASS);

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D),
BlocksTFC.DOUBLE_TALL_GRASS);

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(),
BlocksTFC.getAllPlantBlocks().toArray(new Block[0]));

blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) ->
worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(),
BlocksTFC.getAllDoublePlantBlocks().toArray(new Block[0]));
}

@SubscribeEvent
Expand All @@ -246,6 +264,22 @@ public static void registerColorHandlerItems(ColorHandlerEvent.Item event)

itemColors.registerItemColorHandler((stack, tintIndex) -> tintIndex == 1 ? EnumDyeColor.byDyeDamage(stack.getItemDamage()).getColorValue() : 0xFFFFFF,
ItemsTFC.CERAMICS_UNFIRED_VESSEL_GLAZED, ItemsTFC.CERAMICS_FIRED_VESSEL_GLAZED);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.TALL_GRASS);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.DOUBLE_TALL_GRASS);

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.getAllPlantBlocks().toArray(new BlockPlantTFC[0]));

itemColors.registerItemColorHandler((stack, tintIndex) ->
event.getBlockColors().colorMultiplier(((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()), null, null, tintIndex),
BlocksTFC.getAllDoublePlantBlocks().toArray(new BlockDoublePlantTFC[0]));
}

/**
Expand Down

0 comments on commit 5d81fca

Please sign in to comment.