mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 04:22:32 +00:00
Clean up sprite registration, remove all IDs
This commit is contained in:
1 parent
30aea48952
commit
2155f9eac9
22 files changed
+182
-303
No files matched your search
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -30,7 +31,7 @@ public interface IFruitProvider {
|
||||
/** return the color to use for decorative leaves. Usually the ripe color. */
|
||||
int getDecorativeColor();
|
||||
|
||||
boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos);
|
||||
boolean isFruitLeaf(ITreeGenome genome, World world, BlockPos pos);
|
||||
|
||||
int getRipeningPeriod();
|
||||
|
||||
@@ -59,18 +60,15 @@ public interface IFruitProvider {
|
||||
/* TEXTURE OVERLAY */
|
||||
|
||||
/**
|
||||
* @param genome
|
||||
* @param world
|
||||
* @param pos
|
||||
* @param ripeningTime
|
||||
* Elapsed ripening time for the fruit.
|
||||
* @param fancy
|
||||
* @return IIcon index of the texture to overlay on the leaf block.
|
||||
* @param ripeningTime Elapsed ripening time for the fruit.
|
||||
* @return ResourceLocation of the texture to overlay on the leaf block.
|
||||
*/
|
||||
short getSpriteIndex(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime, boolean fancy);
|
||||
@Nullable
|
||||
ResourceLocation getSprite(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime);
|
||||
|
||||
/** return the sprite index to display on decorative leaves */
|
||||
short getDecorativeSpriteIndex();
|
||||
/** return the ResourceLocation to display on decorative leaves */
|
||||
@Nullable
|
||||
ResourceLocation getDecorativeSprite();
|
||||
|
||||
/**
|
||||
* @return true if this fruit provider requires fruit blocks to spawn, false otherwise.
|
||||
|
||||
@@ -7,7 +7,7 @@ package forestry.api.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Provides icons for leaves. Used by TreeManager.treeFactory.createSpecies()
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
*/
|
||||
public interface ILeafSpriteProvider {
|
||||
@Nonnull
|
||||
TextureAtlasSprite getSprite(boolean pollinated, boolean fancy);
|
||||
ResourceLocation getSprite(boolean pollinated, boolean fancy);
|
||||
|
||||
int getColor(boolean pollinated);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Provides icons, needed in some interfaces, most notably for bees and trees.
|
||||
*/
|
||||
public interface ISpriteProvider {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getSprite(short texUID);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerSprites();
|
||||
|
||||
}
|
||||
@@ -13,9 +13,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ITextureManager {
|
||||
|
||||
void registerIconProvider(ISpriteProvider provider);
|
||||
|
||||
TextureAtlasSprite getSprite(short texUID);
|
||||
|
||||
TextureAtlasSprite getDefault(String ident);
|
||||
|
||||
}
|
||||
@@ -11,8 +11,9 @@ import java.util.Map;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ISpriteProvider;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public interface IAlleleButterflySpecies extends IAlleleSpecies {
|
||||
@@ -64,7 +65,8 @@ public interface IAlleleButterflySpecies extends IAlleleSpecies {
|
||||
|
||||
Map<ItemStack, Float> getCaterpillarLoot();
|
||||
|
||||
ISpriteProvider getSpriteProvider();
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerSprites();
|
||||
|
||||
/**
|
||||
* @return The modid from the mod of the species.
|
||||
|
||||
@@ -18,7 +18,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
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.minecraft.world.World;
|
||||
@@ -27,29 +29,29 @@ import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class FruitProviderNone implements IFruitProvider {
|
||||
|
||||
private static class OverlayType {
|
||||
public final String ident;
|
||||
public final short texUID;
|
||||
public final ResourceLocation sprite;
|
||||
|
||||
public OverlayType(String ident, short texUID) {
|
||||
public OverlayType(String ident) {
|
||||
this.ident = ident;
|
||||
this.texUID = texUID;
|
||||
this.sprite = new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/fruits." + ident);
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashMap<String, OverlayType> overlayTypes = new HashMap<>();
|
||||
|
||||
static {
|
||||
overlayTypes.put("berries", new OverlayType("berries", (short) 1000));
|
||||
overlayTypes.put("pomes", new OverlayType("pomes", (short) 1001));
|
||||
overlayTypes.put("nuts", new OverlayType("nuts", (short) 1002));
|
||||
overlayTypes.put("citrus", new OverlayType("citrus", (short) 1003));
|
||||
overlayTypes.put("plums", new OverlayType("plums", (short) 1004));
|
||||
overlayTypes.put("berries", new OverlayType("berries"));
|
||||
overlayTypes.put("pomes", new OverlayType("pomes"));
|
||||
overlayTypes.put("nuts", new OverlayType("nuts"));
|
||||
overlayTypes.put("citrus", new OverlayType("citrus"));
|
||||
overlayTypes.put("plums", new OverlayType("plums"));
|
||||
}
|
||||
|
||||
private final String unlocalizedDescription;
|
||||
@@ -101,7 +103,7 @@ public class FruitProviderNone implements IFruitProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
public boolean isFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,29 +128,30 @@ public class FruitProviderNone implements IFruitProvider {
|
||||
public String getDescription() {
|
||||
return Translator.translateToLocal(unlocalizedDescription);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getSpriteIndex(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime, boolean fancy) {
|
||||
public ResourceLocation getSprite(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime) {
|
||||
if (overlay != null) {
|
||||
return overlay.texUID;
|
||||
return overlay.sprite;
|
||||
} else {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDecorativeSpriteIndex() {
|
||||
public ResourceLocation getDecorativeSprite() {
|
||||
if (overlay != null) {
|
||||
return overlay.texUID;
|
||||
return overlay.sprite;
|
||||
} else {
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSprites() {
|
||||
if (overlay != null) {
|
||||
TextureManager.registerSpriteUID(overlay.texUID, "blocks/leaves/fruits." + overlay.ident);
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
map.registerSprite(overlay.sprite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,15 +35,8 @@ import forestry.core.utils.BlockUtil;
|
||||
public class FruitProviderPod extends FruitProviderNone {
|
||||
|
||||
public enum EnumPodType {
|
||||
COCOA((short) 2000, (short) 2001, (short) 2002), DATES((short) 2010, (short) 2011, (short) 2012),
|
||||
PAPAYA((short) 2013, (short) 2014, (short) 2015);//, COCONUT((short)2016, (short)2017, (short)2018);
|
||||
COCOA, DATES, PAPAYA;//, COCONUT;
|
||||
|
||||
public final short[] uids;
|
||||
|
||||
EnumPodType(short stage1, short stage2, short stage3) {
|
||||
uids = new short[]{stage1, stage2, stage3};
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
@@ -100,17 +94,13 @@ public class FruitProviderPod extends FruitProviderNone {
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getSpriteIndex(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime, boolean fancy) {
|
||||
if (ripeningTime < 0 || ripeningTime >= type.uids.length) {
|
||||
return getDecorativeSpriteIndex();
|
||||
}
|
||||
return type.uids[ripeningTime];
|
||||
public ResourceLocation getSprite(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDecorativeSpriteIndex() {
|
||||
int index = type.uids.length - 1;
|
||||
return type.uids[index];
|
||||
public ResourceLocation getDecorativeSprite() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -79,7 +79,7 @@ public class FruitProviderRandom extends FruitProviderNone {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
public boolean isFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class FruitProviderRipening extends FruitProviderNone {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
public boolean isFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,23 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
@@ -38,7 +40,6 @@ import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.core.models.ModelBlockDefault;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class ModelDecorativeLeaves extends ModelBlockDefault<BlockDecorativeLeaves> {
|
||||
|
||||
@@ -107,22 +108,26 @@ public class ModelDecorativeLeaves extends ModelBlockDefault<BlockDecorativeLeav
|
||||
return;
|
||||
}
|
||||
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
ITreeGenome genome = treeDefinition.getGenome();
|
||||
IAlleleTreeSpecies species = genome.getPrimary();
|
||||
ILeafSpriteProvider leafSpriteProvider = species.getLeafSpriteProvider();
|
||||
TextureAtlasSprite leaveSprite = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
|
||||
|
||||
ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
|
||||
// Render the plain leaf block.
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leaveSprite, 0);
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
|
||||
|
||||
// Render overlay for fruit leaves.
|
||||
TextureAtlasSprite fruitSprite = TextureManager.getInstance().getSprite(genome.getFruitProvider().getDecorativeSpriteIndex());
|
||||
|
||||
if (fruitSprite != null) {
|
||||
ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(leaveSprite);
|
||||
baker.setParticleSprite(leafSprite);
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,14 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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 forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
@@ -42,6 +45,8 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
TileLeaves leaves = new TileLeaves();
|
||||
if (itemStack.hasTagCompound()) {
|
||||
leaves.readFromNBT(itemStack.getTagCompound());
|
||||
@@ -49,11 +54,12 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
leaves.setTree(TreeRoot.treeTemplates.get(0));
|
||||
}
|
||||
|
||||
TextureAtlasSprite leavesIcon = leaves.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
ResourceLocation leafSpriteLocation = leaves.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leavesIcon = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
if (leavesIcon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leavesIcon, 0);
|
||||
|
||||
// add fruit
|
||||
@@ -61,35 +67,42 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureAtlasSprite fruitTexture = leaves.getFruitSprite();
|
||||
if (fruitTexture == null) {
|
||||
return;
|
||||
ResourceLocation fruitSpriteLocation = leaves.getFruitSprite();
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitTexture = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitTexture, 1);
|
||||
}
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitTexture, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bakeWorldBlock(@Nonnull BlockForestryLeaves block, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IExtendedBlockState stateExtended, @Nonnull IModelBaker baker) {
|
||||
TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class);
|
||||
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
if (tile == null) {
|
||||
IAlleleTreeSpecies oakSpecies = TreeDefinition.Oak.getIndividual().getGenome().getPrimary();
|
||||
baker.setParticleSprite(oakSpecies.getLeafSpriteProvider().getSprite(false, Proxies.render.fancyGraphicsEnabled()));
|
||||
ResourceLocation spriteLocation = oakSpecies.getLeafSpriteProvider().getSprite(false, Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite sprite = map.getAtlasSprite(spriteLocation.toString());
|
||||
baker.setParticleSprite(sprite);
|
||||
return;
|
||||
}
|
||||
|
||||
TextureAtlasSprite leaveSprite = tile.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
ResourceLocation leafSpriteLocation = tile.getLeaveSprite(Proxies.render.fancyGraphicsEnabled());
|
||||
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
|
||||
// Render the plain leaf block.
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, leaveSprite, 0);
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, leafSprite, 0);
|
||||
|
||||
// Render overlay for fruit leaves.
|
||||
TextureAtlasSprite fruitSprite = tile.getFruitSprite();
|
||||
ResourceLocation fruitSpriteLocation = tile.getFruitSprite();
|
||||
|
||||
if (fruitSprite != null) {
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, fruitSprite, 1);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
baker.setParticleSprite(leaveSprite);
|
||||
baker.setParticleSprite(leafSprite);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ package forestry.arboriculture.models;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.arboriculture.EnumLeafType;
|
||||
import forestry.api.arboriculture.ILeafSpriteProvider;
|
||||
@@ -41,7 +41,7 @@ public class SpriteProviderLeaves implements ILeafSpriteProvider {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public TextureAtlasSprite getSprite(boolean pollinated, boolean fancy) {
|
||||
public ResourceLocation getSprite(boolean pollinated, boolean fancy) {
|
||||
return leafTexture.getSprite(pollinated, fancy);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -42,29 +41,29 @@ public class TextureLeaves {
|
||||
}
|
||||
}
|
||||
|
||||
private final EnumLeafType leafType;
|
||||
|
||||
private TextureAtlasSprite plain;
|
||||
private TextureAtlasSprite fancy;
|
||||
private TextureAtlasSprite pollinatedPlain;
|
||||
private TextureAtlasSprite pollinatedFancy;
|
||||
private final ResourceLocation plain;
|
||||
private final ResourceLocation fancy;
|
||||
private final ResourceLocation pollinatedPlain;
|
||||
private final ResourceLocation pollinatedFancy;
|
||||
|
||||
private TextureLeaves(EnumLeafType enumLeafType) {
|
||||
this.leafType = enumLeafType;
|
||||
String ident = enumLeafType.toString().toLowerCase(Locale.ENGLISH);
|
||||
this.plain = new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".plain");
|
||||
this.fancy = new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".fancy");
|
||||
this.pollinatedPlain = new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".changed.plain");
|
||||
this.pollinatedFancy = new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".changed");
|
||||
}
|
||||
|
||||
private void registerSprites() {
|
||||
String ident = leafType.toString().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
TextureMap textureMapBlocks = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
plain = textureMapBlocks.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".plain"));
|
||||
fancy = textureMapBlocks.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".fancy"));
|
||||
pollinatedPlain = textureMapBlocks.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".changed.plain"));
|
||||
pollinatedFancy = textureMapBlocks.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/leaves/" + ident + ".changed"));
|
||||
textureMapBlocks.registerSprite(plain);
|
||||
textureMapBlocks.registerSprite(fancy);
|
||||
textureMapBlocks.registerSprite(pollinatedPlain);
|
||||
textureMapBlocks.registerSprite(pollinatedFancy);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public TextureAtlasSprite getSprite(boolean pollinated, boolean fancy) {
|
||||
public ResourceLocation getSprite(boolean pollinated, boolean fancy) {
|
||||
if (pollinated) {
|
||||
if (fancy) {
|
||||
return this.pollinatedFancy;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.arboriculture.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -19,16 +20,14 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
@@ -58,7 +57,6 @@ import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.packets.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.ColourUtil;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
|
||||
@@ -66,7 +64,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
private int colourFruits;
|
||||
|
||||
private short textureIndexFruits = -1;
|
||||
@Nullable
|
||||
private ResourceLocation fruitSprite;
|
||||
private IAlleleTreeSpecies species;
|
||||
|
||||
private boolean isFruitLeaf;
|
||||
@@ -166,20 +165,20 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
if (tree.canBearFruit()) {
|
||||
IFruitProvider fruitProvider = genome.getFruitProvider();
|
||||
|
||||
isFruitLeaf = fruitProvider.markAsFruitLeaf(genome, worldObj, getPos());
|
||||
isFruitLeaf = fruitProvider.isFruitLeaf(genome, worldObj, getPos());
|
||||
if (isFruitLeaf) {
|
||||
// Hardcoded because vanilla oak trees don't show fruits.
|
||||
if (species == TreeDefinition.Oak.getGenome().getPrimary() && fruitProvider == AlleleFruit.fruitApple.getProvider()) {
|
||||
textureIndexFruits = -1;
|
||||
fruitSprite = null;
|
||||
} else {
|
||||
textureIndexFruits = fruitProvider.getSpriteIndex(genome, worldObj, getPos(), getRipeningTime(), true);
|
||||
fruitSprite = fruitProvider.getSprite(genome, worldObj, getPos(), getRipeningTime());
|
||||
}
|
||||
|
||||
ripeningPeriod = (short) tree.getGenome().getFruitProvider().getRipeningPeriod();
|
||||
}
|
||||
} else {
|
||||
isFruitLeaf = false;
|
||||
textureIndexFruits = -1;
|
||||
fruitSprite = null;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
@@ -230,8 +229,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
return fruit.getColour(genome, worldObj, getPos(), getRipeningTime());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getLeaveSprite(boolean fancy) {
|
||||
@Nonnull
|
||||
public ResourceLocation getLeaveSprite(boolean fancy) {
|
||||
final ILeafSpriteProvider leafSpriteProvider = getLeafSpriteProvider();
|
||||
return leafSpriteProvider.getSprite(isPollinatedState, fancy);
|
||||
}
|
||||
@@ -246,13 +245,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getFruitSprite() {
|
||||
if (textureIndexFruits >= 0) {
|
||||
return TextureManager.getInstance().getSprite(textureIndexFruits);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
public ResourceLocation getFruitSprite() {
|
||||
return fruitSprite;
|
||||
}
|
||||
|
||||
public int getRipeningTime() {
|
||||
@@ -370,15 +365,14 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
IAllele[] treeTemplate = TreeManager.treeRoot.getTemplate(speciesUID);
|
||||
|
||||
if (fruitAlleleUID != null) {
|
||||
IAllele fruitAllele = AlleleManager.alleleRegistry.getAllele(fruitAlleleUID);
|
||||
if (fruitAllele != null) {
|
||||
treeTemplate[EnumTreeChromosome.FRUITS.ordinal()] = fruitAllele;
|
||||
}
|
||||
}
|
||||
|
||||
if (treeTemplate != null) {
|
||||
if (fruitAlleleUID != null) {
|
||||
IAllele fruitAllele = AlleleManager.alleleRegistry.getAllele(fruitAlleleUID);
|
||||
if (fruitAllele != null) {
|
||||
treeTemplate[EnumTreeChromosome.FRUITS.ordinal()] = fruitAllele;
|
||||
}
|
||||
}
|
||||
|
||||
ITree tree = TreeManager.treeRoot.templateAsIndividual(treeTemplate);
|
||||
if (isPollinatedState) {
|
||||
tree.mate(tree);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package forestry.core.errors;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -111,8 +112,7 @@ public enum EnumErrorCode implements IErrorState {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerSprite() {
|
||||
String location = "forestry:gui/errors/" + iconName;
|
||||
texture = TextureManager.registerSprite(new ErrorAtlasSprite(location), location);
|
||||
texture = TextureManager.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "gui/errors/" + iconName));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.errors;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ErrorAtlasSprite extends TextureAtlasSprite {
|
||||
|
||||
public ErrorAtlasSprite(String spriteName) {
|
||||
super(spriteName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,29 +25,24 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpriteProvider;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureManager implements ITextureManager {
|
||||
|
||||
private static final TextureManager instance = new TextureManager();
|
||||
|
||||
private static final TextureManager INSTANCE = new TextureManager();
|
||||
private static final Map<String, TextureAtlasSprite> defaultIcons = new HashMap<>();
|
||||
private static final DefaultSpriteProvider defaultIconProvider = new DefaultSpriteProvider();
|
||||
private static final List<ISpriteProvider> iconProviders = new ArrayList<>();
|
||||
|
||||
private final List<ISpriteRegister> spriteRegisters = new ArrayList<>();
|
||||
|
||||
static {
|
||||
ForestryAPI.textureManager = instance;
|
||||
instance.registerIconProvider(defaultIconProvider);
|
||||
ForestryAPI.textureManager = INSTANCE;
|
||||
}
|
||||
|
||||
public static TextureManager getInstance() {
|
||||
return instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private TextureManager() {
|
||||
@@ -63,73 +58,22 @@ public class TextureManager implements ITextureManager {
|
||||
"errors/errored", "errors/unknown",
|
||||
"slots/blocked", "slots/blocked_2", "slots/liquid", "slots/container", "slots/locked",
|
||||
"mail/carrier.player", "mail/carrier.trader"};
|
||||
for (String str : defaultIconNames) {
|
||||
TextureAtlasSprite icon = registerSprite("gui/" + str);
|
||||
defaultIcons.put(str, icon);
|
||||
for (String identifier : defaultIconNames) {
|
||||
ResourceLocation resourceLocation = new ResourceLocation(Constants.RESOURCE_ID, "gui/" + identifier);
|
||||
TextureAtlasSprite icon = registerSprite(resourceLocation);
|
||||
defaultIcons.put(identifier, icon);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite registerSprite(String identifier) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
return map.registerSprite(new ResourceLocation("forestry:" + identifier));
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite registerSprite(TextureAtlasSprite sprite, String identifier) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
if(map.setTextureEntry(identifier, sprite)){
|
||||
return sprite;
|
||||
}else{
|
||||
return map.getTextureExtry(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getSprite(String modID, String identifier) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
if (map.getAtlasSprite(new ResourceLocation(modID + ":" + identifier).toString()) == map.getMissingSprite()) {
|
||||
return map.registerSprite(new ResourceLocation(modID + ":" + identifier));
|
||||
}
|
||||
return map.getAtlasSprite(new ResourceLocation(modID + ":" + identifier).toString());
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getSprite(String modID, String modifier, String identifier) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
if (map.getAtlasSprite(new ResourceLocation(modID + ":" + modifier + "/" + identifier).toString()) == map.getMissingSprite()) {
|
||||
return map.registerSprite(new ResourceLocation(modID + ":" + modifier + "/" + identifier));
|
||||
}
|
||||
return map.getAtlasSprite(new ResourceLocation(modID + ":" + modifier + "/" + identifier).toString());
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite registerSpriteUID(short uid, String identifier) {
|
||||
TextureAtlasSprite texture = registerSprite(identifier);
|
||||
defaultIconProvider.addTexture(uid, texture);
|
||||
return texture;
|
||||
public static TextureAtlasSprite registerSprite(ResourceLocation location) {
|
||||
TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
return textureMap.registerSprite(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getDefault(String ident) {
|
||||
return defaultIcons.get(ident);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIconProvider(ISpriteProvider provider) {
|
||||
iconProviders.add(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getSprite(short texUID) {
|
||||
if (texUID < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ISpriteProvider provider : iconProviders) {
|
||||
TextureAtlasSprite icon = provider.getSprite(texUID);
|
||||
if (icon != null) {
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerBlock(Block block) {
|
||||
if (block instanceof ISpriteRegister) {
|
||||
@@ -149,22 +93,4 @@ public class TextureManager implements ITextureManager {
|
||||
spriteRegister.registerSprites(getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
private static class DefaultSpriteProvider implements ISpriteProvider {
|
||||
private final Map<Short, TextureAtlasSprite> textures = new HashMap<>();
|
||||
|
||||
public void addTexture(short texUID, TextureAtlasSprite texture) {
|
||||
textures.put(texUID, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getSprite(short texUID) {
|
||||
return textures.get(texUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSprites() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,15 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public enum EnumFarmBlockType implements IStringSerializable {
|
||||
PLAIN,
|
||||
@@ -36,15 +39,16 @@ public enum EnumFarmBlockType implements IStringSerializable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerSprites() {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
sprites = Arrays.asList(
|
||||
TextureManager.registerSprite("blocks/farm/plain"),
|
||||
TextureManager.registerSprite("blocks/farm/reverse"),
|
||||
TextureManager.registerSprite("blocks/farm/top"),
|
||||
TextureManager.registerSprite("blocks/farm/band"),
|
||||
TextureManager.registerSprite("blocks/farm/gears"),
|
||||
TextureManager.registerSprite("blocks/farm/hatch"),
|
||||
TextureManager.registerSprite("blocks/farm/valve"),
|
||||
TextureManager.registerSprite("blocks/farm/control")
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/plain")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/reverse")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/top")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/band")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/gears")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/hatch")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/valve")),
|
||||
map.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/farm/control"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.models;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -18,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public enum EnumFarmBlockTexture {
|
||||
BRICK_STONE(new ItemStack(Blocks.STONEBRICK, 1, 0)),
|
||||
@@ -44,50 +45,51 @@ public enum EnumFarmBlockTexture {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getSprite(EnumFarmBlockTexture texture, int side) {
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
switch (texture) {
|
||||
case BRICK:
|
||||
return TextureManager.getSprite("minecraft", "blocks/brick");
|
||||
return map.getAtlasSprite("minecraft:blocks/brick");
|
||||
case BRICK_STONE:
|
||||
return TextureManager.getSprite("minecraft", "blocks/stonebrick");
|
||||
return map.getAtlasSprite("minecraft:blocks/stonebrick");
|
||||
case BRICK_CHISELED:
|
||||
return TextureManager.getSprite("minecraft", "blocks/stonebrick_carved");
|
||||
return map.getAtlasSprite("minecraft:blocks/stonebrick_carved");
|
||||
case BRICK_CRACKED:
|
||||
return TextureManager.getSprite("minecraft", "blocks/stonebrick_cracked");
|
||||
return map.getAtlasSprite("minecraft:blocks/stonebrick_cracked");
|
||||
case BRICK_MOSSY:
|
||||
return TextureManager.getSprite("minecraft", "blocks/stonebrick_mossy");
|
||||
return map.getAtlasSprite("minecraft:blocks/stonebrick_mossy");
|
||||
case BRICK_NETHER:
|
||||
return TextureManager.getSprite("minecraft", "blocks/nether_brick");
|
||||
return map.getAtlasSprite("minecraft:blocks/nether_brick");
|
||||
case SANDSTONE_CHISELED:
|
||||
if (side == 0) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_bottom");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_bottom");
|
||||
} else if (side == 1) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_top");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_top");
|
||||
}
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_carved");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_carved");
|
||||
case SANDSTONE_SMOOTH:
|
||||
if (side == 0) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_bottom");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_bottom");
|
||||
} else if (side == 1) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_top");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_top");
|
||||
}
|
||||
return TextureManager.getSprite("minecraft", "blocks/sandstone_smooth");
|
||||
return map.getAtlasSprite("minecraft:blocks/sandstone_smooth");
|
||||
case QUARTZ:
|
||||
if (side == 0) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_bottom");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_bottom");
|
||||
} else if (side == 1) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_top");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_top");
|
||||
}
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_side");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_side");
|
||||
case QUARTZ_CHISELED:
|
||||
if (side == 0 || side == 1) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_chiseled_top");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_chiseled_top");
|
||||
}
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_chiseled");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_chiseled");
|
||||
case QUARTZ_LINES:
|
||||
if (side == 0 || side == 1) {
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_lines_top");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_lines_top");
|
||||
}
|
||||
return TextureManager.getSprite("minecraft", "blocks/quartz_block_lines");
|
||||
return map.getAtlasSprite("minecraft:blocks/quartz_block_lines");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,18 @@ import java.util.Locale;
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse.State;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseHatch;
|
||||
|
||||
@@ -76,13 +79,17 @@ public enum BlockGreenhouseType {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerSprites() {
|
||||
sprites = new EnumMap<>(BlockGreenhouseSprites.class);
|
||||
TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
|
||||
for (BlockGreenhouseSprites sprite : BlockGreenhouseSprites.VALUES) {
|
||||
if (sprite == BlockGreenhouseSprites.PLAIN) {
|
||||
sprites.put(sprite, TextureManager.getSprite("minecraft", "blocks/brick"));
|
||||
sprites.put(sprite, map.getAtlasSprite("minecraft:blocks/brick"));
|
||||
} else if (sprite == BlockGreenhouseSprites.GLASS) {
|
||||
sprites.put(sprite, TextureManager.getSprite("minecraft", "blocks/glass_green"));
|
||||
sprites.put(sprite, map.getAtlasSprite("minecraft:blocks/glass_green"));
|
||||
} else {
|
||||
sprites.put(sprite, TextureManager.registerSprite("blocks/greenhouse/" + sprite.spriteName));
|
||||
ResourceLocation location = new ResourceLocation(Constants.RESOURCE_ID, "blocks/greenhouse/" + sprite.spriteName);
|
||||
TextureAtlasSprite textureAtlasSprite = map.registerSprite(location);
|
||||
sprites.put(sprite, textureAtlasSprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-14
@@ -16,7 +16,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,7 +27,6 @@ import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ISpriteProvider;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -42,7 +40,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.genetics.alleles.AlleleSpecies;
|
||||
import forestry.lepidopterology.render.TextureAtlasButterfly;
|
||||
|
||||
public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButterflySpecies, IAlleleButterflySpeciesBuilder, ISpriteProvider {
|
||||
public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButterflySpecies, IAlleleButterflySpeciesBuilder {
|
||||
private final String texture;
|
||||
private final String modID;
|
||||
private final Color serumColour;
|
||||
@@ -195,11 +193,6 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpriteProvider getSpriteProvider() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -208,12 +201,6 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
textureMap.setTextureEntry(spriteName, new TextureAtlasButterfly(spriteName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(short texUID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
|
||||
@@ -294,7 +294,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
public void registerSprites(ITextureManager manager) {
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleButterflySpecies) {
|
||||
((IAlleleButterflySpecies) allele).getSpriteProvider().registerSprites();
|
||||
((IAlleleButterflySpecies) allele).registerSprites();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user