Fix #1963 Forestry leaves confuse minimap mods

This commit is contained in:
Nedelosk committed 2018-02-16 17:55:40 +01:00
1 parent 0f494d4ac7
commit 31b83ea852
9 files changed
+64 -46

No files matched your search

@@ -43,6 +43,9 @@ import forestry.core.utils.BlockUtil;
* Parent class for shared behavior between {@link BlockDefaultLeaves} and {@link BlockForestryLeaves}
*/
public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemModelRegister, IColoredBlock {
public static final int FOLIAGE_COLOR_INDEX = 1;
public static final int FRUIT_COLOR_INDEX = 0;
@Nullable
protected abstract ITree getTree(IBlockAccess world, BlockPos pos);
@@ -109,10 +109,10 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR
@Override
public boolean isOpaqueCube(IBlockState state) {
if(!Proxies.render.fancyGraphicsEnabled()){
TreeDefinition treeDefinition = state.getValue(getVariant());
return !TreeDefinition.Willow.equals(treeDefinition);
return true;
}
return false;
TreeDefinition treeDefinition = state.getValue(getVariant());
return !TreeDefinition.Willow.equals(treeDefinition);
}
@Override
@@ -214,7 +214,7 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR
TreeDefinition treeDefinition = state.getValue(getVariant());
ITreeGenome genome = treeDefinition.getGenome();
if (tintIndex == 0) {
if (tintIndex == BlockAbstractLeaves.FOLIAGE_COLOR_INDEX) {
return genome.getPrimary().getLeafSpriteProvider().getColor(false);
} else {
IFruitProvider fruitProvider = genome.getFruitProvider();
@@ -194,7 +194,7 @@ public abstract class BlockDefaultLeaves extends BlockAbstractLeaves {
}
ITreeGenome genome = treeDefinition.getGenome();
if (tintIndex == 0) {
if (tintIndex == BlockAbstractLeaves.FOLIAGE_COLOR_INDEX) {
return genome.getPrimary().getLeafSpriteProvider().getColor(false);
} else {
IFruitProvider fruitProvider = genome.getFruitProvider();
@@ -207,7 +207,7 @@ public class BlockForestryLeaves extends BlockAbstractLeaves implements ITileEnt
if (worldIn != null && pos != null) {
TileLeaves leaves = TileUtil.getTile(worldIn, pos, TileLeaves.class);
if (leaves != null) {
if (tintIndex == 0) {
if (tintIndex == BlockAbstractLeaves.FOLIAGE_COLOR_INDEX) {
EntityPlayer thePlayer = Minecraft.getMinecraft().player;
return leaves.getFoliageColour(thePlayer);
} else {
@@ -1,14 +1,17 @@
package forestry.arboriculture.items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.arboriculture.blocks.BlockAbstractLeaves;
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.items.IColoredItem;
import forestry.core.items.ItemBlockForestry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBlockDecorativeLeaves extends ItemBlockForestry<BlockDecorativeLeaves> implements IColoredItem {
public ItemBlockDecorativeLeaves(BlockDecorativeLeaves block) {
@@ -33,7 +36,7 @@ public class ItemBlockDecorativeLeaves extends ItemBlockForestry<BlockDecorative
ITreeGenome genome = treeDefinition.getGenome();
if (renderPass == 0) {
if (renderPass == BlockAbstractLeaves.FOLIAGE_COLOR_INDEX) {
return genome.getPrimary().getLeafSpriteProvider().getColor(false);
} else {
IFruitProvider fruitProvider = genome.getFruitProvider();
@@ -70,7 +70,7 @@ public class ItemBlockLeaves extends ItemBlockForestry<BlockAbstractLeaves> impl
TileLeaves tileLeaves = new TileLeaves();
tileLeaves.readFromNBT(itemStack.getTagCompound());
if (renderPass == 0) {
if (renderPass == BlockAbstractLeaves.FOLIAGE_COLOR_INDEX) {
EntityPlayer player = Minecraft.getMinecraft().player;
return tileLeaves.getFoliageColour(player);
} else {
@@ -11,15 +11,7 @@
package forestry.arboriculture.models;
import com.google.common.base.Preconditions;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.models.ModelBlockCached;
import forestry.core.models.baker.ModelBaker;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -28,9 +20,21 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockAbstractLeaves;
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.models.ModelBlockCached;
import forestry.core.models.baker.ModelBaker;
import forestry.core.proxy.Proxies;
@SideOnly(Side.CLIENT)
public class ModelDecorativeLeaves extends ModelBlockCached<BlockDecorativeLeaves, TreeDefinition> {
public ModelDecorativeLeaves() {
@@ -65,13 +69,13 @@ public class ModelDecorativeLeaves extends ModelBlockCached<BlockDecorativeLeave
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(null, leafSprite, 0);
baker.addBlockModel(null, leafSprite, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(null, fruitSprite, 1);
baker.addBlockModel(null, fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
}
// Set the particle sprite
@@ -11,15 +11,7 @@
package forestry.arboriculture.models;
import com.google.common.base.Preconditions;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockDefaultLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.models.ModelBlockCached;
import forestry.core.models.baker.ModelBaker;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -28,9 +20,21 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockAbstractLeaves;
import forestry.arboriculture.blocks.BlockDefaultLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.models.ModelBlockCached;
import forestry.core.models.baker.ModelBaker;
import forestry.core.proxy.Proxies;
@SideOnly(Side.CLIENT)
public class ModelDefaultLeaves extends ModelBlockCached<BlockDefaultLeaves, TreeDefinition> {
public ModelDefaultLeaves() {
@@ -67,13 +71,13 @@ public class ModelDefaultLeaves extends ModelBlockCached<BlockDefaultLeaves, Tre
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(null, leafSprite, 0);
baker.addBlockModel(null, leafSprite, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(null, fruitSprite, 1);
baker.addBlockModel(null, fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
}
// Set the particle sprite
@@ -13,8 +13,23 @@ package forestry.arboriculture.models;
import javax.annotation.Nullable;
import java.util.Objects;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockAbstractLeaves;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.genetics.TreeRoot;
@@ -24,17 +39,6 @@ import forestry.core.blocks.properties.UnlistedBlockPos;
import forestry.core.models.ModelBlockCached;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelLeaves extends ModelBlockCached<BlockForestryLeaves, ModelLeaves.Key> {
@@ -125,10 +129,10 @@ public class ModelLeaves extends ModelBlockCached<BlockForestryLeaves, ModelLeav
@Override
protected void bakeBlock(BlockForestryLeaves block, Key key, IModelBaker baker, boolean inventory) {
// Render the plain leaf block.
baker.addBlockModel(null, key.leafSprite, 0);
baker.addBlockModel(null, key.leafSprite, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
if (key.fruitSprite != null) {
baker.addBlockModel(null, key.fruitSprite, 1);
baker.addBlockModel(null, key.fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
}
// Set the particle sprite