mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Cleanup, move ILeafSpriteProvider around
This commit is contained in:
1 parent
315e5ba1cf
commit
2f711b0493
8 files changed
+44
-56
No files matched your search
@@ -10,7 +10,7 @@ import forestry.api.genetics.IAllele;
|
||||
/**
|
||||
* Simple allele encapsulating an {@link IFruitProvider}.
|
||||
*/
|
||||
public interface IAlleleFruit extends IAllele, Comparable<IAlleleFruit> {
|
||||
public interface IAlleleFruit extends IAllele {
|
||||
|
||||
IFruitProvider getProvider();
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ package forestry.api.arboriculture;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
@@ -18,7 +17,7 @@ import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
|
||||
public interface IAlleleTreeSpecies extends IAlleleSpecies<TreeChromosome>, Comparable<IAlleleTreeSpecies> {
|
||||
public interface IAlleleTreeSpecies extends IAlleleSpecies<TreeChromosome> {
|
||||
|
||||
@Override
|
||||
ITreeRoot getRoot();
|
||||
@@ -49,10 +48,8 @@ public interface IAlleleTreeSpecies extends IAlleleSpecies<TreeChromosome>, Comp
|
||||
String getModelName();
|
||||
|
||||
/* TEXTURES AND OVERRIDES */
|
||||
int getLeafColour(boolean pollinated);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getLeafSprite(boolean pollinated, boolean fancy);
|
||||
ILeafSpriteProvider getLeafSpriteProvider();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ModelResourceLocation getGermlingModel(EnumGermlingType type);
|
||||
|
||||
@@ -8,7 +8,7 @@ package forestry.api.genetics;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
public interface IAlleleSpeciesBuilder<C extends IChromosomeType<C>> {
|
||||
public interface IAlleleSpeciesBuilder<C extends IChromosomeType> {
|
||||
|
||||
IAlleleSpecies<C> build();
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@@ -281,19 +283,19 @@ public class BlockForestryLeaves extends BlockLeavesBase implements ITileEntityP
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass) {
|
||||
TileLeaves leaves = getLeafTile(world, pos);
|
||||
if (leaves == null) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
return super.colorMultiplier(world, pos, renderPass);
|
||||
}
|
||||
|
||||
final int colour;
|
||||
if (renderPass == 0) {
|
||||
colour = leaves.getFoliageColour(Proxies.common.getClientInstance().thePlayer);
|
||||
if (colour == 0 || colour == PluginArboriculture.proxy.getFoliageColorBasic()) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
}
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||
colour = leaves.getFoliageColour(thePlayer);
|
||||
} else {
|
||||
colour = leaves.getFruitColour();
|
||||
if (colour == 0) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (colour == 0) {
|
||||
return super.colorMultiplier(world, pos, renderPass);
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
|
||||
@@ -87,11 +87,6 @@ public class AlleleFruit extends AlleleCategorized implements IAlleleFruit {
|
||||
return getProvider().getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull IAlleleFruit arg0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelName() {
|
||||
return getProvider().getModelName();
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics.alleles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
@@ -40,10 +38,10 @@ import forestry.core.genetics.alleles.AlleleSpecies;
|
||||
public class AlleleTreeSpecies extends AlleleSpecies<TreeChromosome> implements IAlleleTreeSpecies, IAlleleTreeSpeciesBuilder {
|
||||
private final ITreeGenerator generator;
|
||||
private final IGermlingModelProvider germlingModelProvider;
|
||||
private final ILeafSpriteProvider leafmodelProvider;
|
||||
private final ILeafSpriteProvider leafSpriteProvider;
|
||||
private final List<IFruitFamily> fruits = new ArrayList<>();
|
||||
|
||||
private final String mdoelName;
|
||||
private final String modelName;
|
||||
|
||||
private EnumPlantType nativeType = EnumPlantType.Plains;
|
||||
|
||||
@@ -52,8 +50,8 @@ public class AlleleTreeSpecies extends AlleleSpecies<TreeChromosome> implements
|
||||
|
||||
this.generator = generator;
|
||||
this.germlingModelProvider = germlingModelProvider;
|
||||
this.leafmodelProvider = leafIconProvider;
|
||||
this.mdoelName = modelName;
|
||||
this.leafSpriteProvider = leafIconProvider;
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
// TODO: break this into a separate builder class
|
||||
@@ -97,18 +95,13 @@ public class AlleleTreeSpecies extends AlleleSpecies<TreeChromosome> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getLeafSprite(boolean pollinated, boolean fancy) {
|
||||
return leafmodelProvider.getSprite(pollinated, fancy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeafColour(boolean pollinated) {
|
||||
return leafmodelProvider.getColor(pollinated);
|
||||
public ILeafSpriteProvider getLeafSpriteProvider() {
|
||||
return leafSpriteProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpriteColour(int renderPass) {
|
||||
return leafmodelProvider.getColor(false);
|
||||
return leafSpriteProvider.getColor(false);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -123,7 +116,7 @@ public class AlleleTreeSpecies extends AlleleSpecies<TreeChromosome> implements
|
||||
if (type == EnumGermlingType.SAPLING) {
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
return getLeafColour(false);
|
||||
return getSpriteColour(renderPass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,12 +131,7 @@ public class AlleleTreeSpecies extends AlleleSpecies<TreeChromosome> implements
|
||||
|
||||
@Override
|
||||
public String getModelName() {
|
||||
return mdoelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull IAlleleTreeSpecies o) {
|
||||
return 0;
|
||||
return modelName;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -66,7 +66,8 @@ public class ItemBlockLeaves extends ItemBlockForestry {
|
||||
if (renderPass == 1) {
|
||||
return tileLeaves.getFruitColour();
|
||||
} else {
|
||||
return tileLeaves.getFoliageColour(Proxies.common.getPlayer());
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
return tileLeaves.getFoliageColour(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
import forestry.api.arboriculture.ILeafTickHandler;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
@@ -69,8 +70,7 @@ import forestry.core.utils.PlayerUtil;
|
||||
|
||||
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery, IRipeningPacketReceiver {
|
||||
|
||||
private int colourLeaves;
|
||||
private int colourLeavesPollinated;
|
||||
private ILeafSpriteProvider leafSpriteProvider;
|
||||
private int colourFruits;
|
||||
|
||||
private short textureIndexFruits = -1;
|
||||
@@ -239,13 +239,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
textureIndexFruits = -1;
|
||||
}
|
||||
|
||||
colourLeaves = species.getLeafColour(false);
|
||||
colourLeavesPollinated = species.getLeafColour(true);
|
||||
if (isDestroyed(tree, damage)) {
|
||||
colourLeaves = ColourUtil.addRGBComponents(colourLeaves, 92, 61, 0);
|
||||
} else if (caterpillar != null) {
|
||||
colourLeaves = ColourUtil.multiplyRGBComponents(colourLeaves, 1.5f);
|
||||
}
|
||||
leafSpriteProvider = species.getLeafSpriteProvider();
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -264,10 +259,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
public int getFoliageColour(EntityPlayer player) {
|
||||
if (isPollinatedState && GeneticsUtil.hasNaturalistEye(player)) {
|
||||
return colourLeavesPollinated;
|
||||
final boolean showPollinated = isPollinatedState && GeneticsUtil.hasNaturalistEye(player);
|
||||
final int baseColor = leafSpriteProvider.getColor(showPollinated);
|
||||
|
||||
ITree tree = getTree();
|
||||
if (isDestroyed(tree, damage)) {
|
||||
return ColourUtil.addRGBComponents(baseColor, 92, 61, 0);
|
||||
} else if (caterpillar != null) {
|
||||
return ColourUtil.multiplyRGBComponents(baseColor, 1.5f);
|
||||
} else {
|
||||
return colourLeaves;
|
||||
return baseColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,10 +288,14 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getLeaveSprite(boolean fancy) {
|
||||
final ILeafSpriteProvider leafSpriteProvider;
|
||||
if (species == null) {
|
||||
return TreeDefinition.Oak.getIndividual().getGenome().getPrimary().getLeafSprite(false, fancy);
|
||||
IAlleleTreeSpecies oakSpecies = TreeDefinition.Oak.getIndividual().getGenome().getPrimary();
|
||||
leafSpriteProvider = oakSpecies.getLeafSpriteProvider();
|
||||
} else {
|
||||
leafSpriteProvider = species.getLeafSpriteProvider();
|
||||
}
|
||||
return species.getLeafSprite(isPollinatedState, fancy);
|
||||
return leafSpriteProvider.getSprite(isPollinatedState, fancy);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
Reference in new issue
Block a user