mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-25 22:34:33 +00:00
Model System Clean Up
This commit is contained in:
1 parent
78d836bc1f
commit
c9b2f7bd3e
42 files changed
+168
-223
No files matched your search
@@ -45,7 +45,13 @@ public class ForestryAPI {
|
||||
* A {@link IModelManager} needed for some things in the API.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IModelManager modleManager;
|
||||
public static IModelManager modelManager;
|
||||
|
||||
/**
|
||||
* A {@link IModelBaker} to bake custom models
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IModelBaker modelBaker;
|
||||
|
||||
/**
|
||||
* The currently active {@link IGameMode}.
|
||||
|
||||
@@ -9,10 +9,13 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A model baker to make custom models in the mod
|
||||
* A model baker to make custom models
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IModelBaker {
|
||||
|
||||
void setRenderBoundsFromBlock(Block block);
|
||||
|
||||
@@ -21,26 +21,18 @@ public interface IModelManager {
|
||||
|
||||
void registerItemModel(Item item, int meta, boolean withMeta);
|
||||
|
||||
ModelResourceLocation getModelLocation(String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(String modID, String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item, String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item, String modifier, String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item, int meta);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item, int meta, String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(Item item, int meta, String modifier, String identifier);
|
||||
ModelResourceLocation getModelLocation(String identifier);
|
||||
|
||||
ModelResourceLocation getModelLocation(String modID, String identifier);
|
||||
|
||||
void registerItemModel(Item item, ItemMeshDefinition definition);
|
||||
|
||||
void registerVariant(Item item, ResourceLocation... resources);
|
||||
|
||||
IModelBaker createNewRenderer();
|
||||
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -123,7 +123,9 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, IItemModelR
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
if(!isFireproof()){
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
}
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@@ -201,22 +203,19 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, IItemModelR
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state)
|
||||
{
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state){
|
||||
int idx = this.getMetaFromState(state);
|
||||
this.harvestTool[idx] = toolClass;
|
||||
this.harvestLevel[idx] = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHarvestTool(IBlockState state)
|
||||
{
|
||||
public String getHarvestTool(IBlockState state){
|
||||
return harvestTool[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(IBlockState state)
|
||||
{
|
||||
public int getHarvestLevel(IBlockState state){
|
||||
return harvestLevel[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,9 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemMode
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
if(!isFireproof()){
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
}
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@@ -154,22 +156,19 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemMode
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state)
|
||||
{
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state){
|
||||
int idx = this.getMetaFromState(state);
|
||||
this.harvestTool[idx] = toolClass;
|
||||
this.harvestLevel[idx] = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHarvestTool(IBlockState state)
|
||||
{
|
||||
public String getHarvestTool(IBlockState state){
|
||||
return harvestTool[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(IBlockState state)
|
||||
{
|
||||
public int getHarvestLevel(IBlockState state){
|
||||
return harvestLevel[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,6 @@ public class BlockForestryLeaves extends BlockLeavesBase implements ITileEntityP
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass) {
|
||||
|
||||
TileLeaves leaves = getLeafTile(world,pos);
|
||||
if (leaves == null) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
@@ -285,12 +284,14 @@ public class BlockForestryLeaves extends BlockLeavesBase implements ITileEntityP
|
||||
int colour = super.colorMultiplier(world, pos, 0);
|
||||
if(renderPass == 0){
|
||||
colour = leaves.getFoliageColour(Proxies.common.getClientInstance().thePlayer);
|
||||
if (colour == PluginArboriculture.proxy.getFoliageColorBasic()) {
|
||||
if (colour == 0 || colour == PluginArboriculture.proxy.getFoliageColorBasic()) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
colour = leaves.getFruitColour();
|
||||
if (colour == 0) {
|
||||
return super.colorMultiplier(world, pos, 0);
|
||||
}
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,11 @@ public class BlockFruitPod extends BlockCocoa implements IStateMapperRegister {
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileFruitPod sapling = (TileFruitPod) world.getTileEntity(pos);
|
||||
IAlleleFruit fruit = sapling.getAllele();
|
||||
state = state.withProperty(FRUIT, fruit);
|
||||
TileFruitPod pot = getPodTile(world, pos);
|
||||
if(pos != null){
|
||||
IAlleleFruit fruit = pot.getAllele();
|
||||
state = state.withProperty(FRUIT, fruit);
|
||||
}
|
||||
return super.getActualState(state, world, pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
@@ -99,7 +97,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
if(world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileSapling){
|
||||
if(world.getTileEntity(pos) instanceof TileSapling){
|
||||
TileSapling sapling = (TileSapling) world.getTileEntity(pos);
|
||||
IAlleleTreeSpecies species = sapling.getTree().getGenome().getPrimary();
|
||||
state = state.withProperty(TREE, species);
|
||||
@@ -125,8 +123,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
}
|
||||
|
||||
/* PLANTING */
|
||||
@Override
|
||||
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) {
|
||||
public boolean canBlockStay(IBlockAccess world, BlockPos pos) {
|
||||
TileSapling tile = getSaplingTile(world, pos);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
@@ -141,7 +138,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) {
|
||||
super.onNeighborBlockChange(world, pos, state, neighborBlock);
|
||||
if (!world.isRemote && !this.canSustainPlant(world, pos, null, null)) {
|
||||
if (!world.isRemote && !this.canBlockStay(world, pos)) {
|
||||
dropAsSapling(world, pos);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,9 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
if(!isFireproof()){
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
}
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@@ -248,22 +250,19 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state)
|
||||
{
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state){
|
||||
int idx = this.getMetaFromState(state);
|
||||
this.harvestTool[idx] = toolClass;
|
||||
this.harvestLevel[idx] = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHarvestTool(IBlockState state)
|
||||
{
|
||||
public String getHarvestTool(IBlockState state){
|
||||
return harvestTool[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(IBlockState state)
|
||||
{
|
||||
public int getHarvestLevel(IBlockState state){
|
||||
return harvestLevel[getMetaFromState(state)];
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -91,7 +91,9 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, II
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
if(!isFireproof()){
|
||||
manager.registerVariant(item, ItemBlockWood.getVariants(this));
|
||||
}
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@@ -163,22 +165,19 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state)
|
||||
{
|
||||
public void setHarvestLevel(String toolClass, int level, IBlockState state) {
|
||||
int idx = this.getMetaFromState(state);
|
||||
this.harvestTool[idx] = toolClass;
|
||||
this.harvestLevel[idx] = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHarvestTool(IBlockState state)
|
||||
{
|
||||
public String getHarvestTool(IBlockState state){
|
||||
return harvestTool[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(IBlockState state)
|
||||
{
|
||||
public int getHarvestLevel(IBlockState state){
|
||||
return harvestLevel[getMetaFromState(state)];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PropertyFruit extends PropertyAllele<IAlleleFruit> {
|
||||
|
||||
@Override
|
||||
public Collection<IAlleleFruit> getAllowedValues() {
|
||||
List<IAlleleFruit> trees = new ArrayList<>();
|
||||
List<IAlleleFruit> trees = new ArrayList();
|
||||
for(IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()){
|
||||
if(allele instanceof IAlleleFruit)
|
||||
if(((IAlleleFruit) allele).getModelName() != null)
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ItemBlockWood extends ItemBlockForestry {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
EnumWoodType type = getWoodType(stack);
|
||||
return ModelManager.getInstance().getModelLocation(stack.getItem(), 0, modifier, type.name().toLowerCase());
|
||||
return ModelManager.getInstance().getModelLocation(modifier + "/" + type.name().toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public class ModelLeaves extends ModelBlockOverlay<BlockForestryLeaves> {
|
||||
|
||||
@Override
|
||||
public void renderInventory(BlockForestryLeaves block, ItemStack itemStack, IModelBaker baker) {
|
||||
|
||||
if (!(itemStack.getItem() instanceof ItemBlockLeaves) || block == null) {
|
||||
return;
|
||||
}
|
||||
@@ -72,7 +71,6 @@ public class ModelLeaves extends ModelBlockOverlay<BlockForestryLeaves> {
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(BlockForestryLeaves block, IBlockAccess world, BlockPos pos, IModelBaker baker) {
|
||||
|
||||
TileLeaves tile = BlockForestryLeaves.getLeafTile(world, pos);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
@@ -92,7 +90,6 @@ public class ModelLeaves extends ModelBlockOverlay<BlockForestryLeaves> {
|
||||
}
|
||||
|
||||
private boolean renderFruitOverlay(IBlockAccess world, BlockForestryLeaves block, BlockPos pos, IModelBaker baker, TextureAtlasSprite sprite, int colorIndex) {
|
||||
|
||||
// Bottom
|
||||
renderBottomFace(world, block, pos, baker, sprite, colorIndex);
|
||||
renderTopFace(world, block, pos, baker, sprite, colorIndex);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package forestry.core.blocks;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IBlockTypeTesr extends IBlockType {
|
||||
@Override
|
||||
@Nonnull
|
||||
IMachinePropertiesTesr<?> getMachineProperties();
|
||||
}
|
||||
@@ -10,16 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.blocks.propertys;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
||||
public abstract class PropertyAllele<A extends IAllele & Comparable<A>> implements IProperty<A> {
|
||||
|
||||
protected final String name;
|
||||
protected final List<A> alleles = new ArrayList<A>();
|
||||
|
||||
public PropertyAllele(String name){
|
||||
this.name = name;
|
||||
@@ -40,8 +36,8 @@ public abstract class PropertyAllele<A extends IAllele & Comparable<A>> implemen
|
||||
}
|
||||
else if (object != null && this.getClass() == object.getClass())
|
||||
{
|
||||
PropertyAllele propertyhelper = (PropertyAllele)object;
|
||||
return this.name.equals(propertyhelper.name);
|
||||
PropertyAllele propertyAllele = (PropertyAllele)object;
|
||||
return name.equals(propertyAllele.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockStateBase;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
@@ -28,9 +28,10 @@ import java.util.List;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
|
||||
/**
|
||||
* A ovelay block model to make a block with 2 or more layers
|
||||
* A overlay block model to make a block with 2 or more texture layers
|
||||
*/
|
||||
public abstract class ModelBlockOverlay<B extends Block> implements ISmartItemModel, ISmartBlockModel {
|
||||
|
||||
@@ -144,7 +145,7 @@ public abstract class ModelBlockOverlay<B extends Block> implements ISmartItemMo
|
||||
|
||||
@Override
|
||||
public IBakedModel handleBlockState(IBlockState state) {
|
||||
IModelBaker baker = ModelManager.getInstance().createNewRenderer();
|
||||
IModelBaker baker = ModelBaker.getInstance();
|
||||
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
|
||||
|
||||
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
|
||||
@@ -163,7 +164,7 @@ public abstract class ModelBlockOverlay<B extends Block> implements ISmartItemMo
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack) {
|
||||
IModelBaker baker = ModelManager.getInstance().createNewRenderer();
|
||||
IModelBaker baker = ModelBaker.getInstance();
|
||||
Block block = Block.getBlockFromItem(stack.getItem());
|
||||
|
||||
block.setBlockBoundsForItemRender();
|
||||
|
||||
@@ -15,12 +15,9 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
@@ -29,26 +26,20 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.ServerStatusResponse.MinecraftProtocolVersionIdentifier;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ItemModelMesherForge;
|
||||
import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ISmartItemModel;
|
||||
import net.minecraftforge.client.model.ItemLayerModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.MultiModel;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
@@ -59,6 +50,8 @@ import forestry.core.items.ItemCrated;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginStorage;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCrate implements ISmartItemModel {
|
||||
|
||||
private HashMap<String, MultiModel.Baked> crates = Maps.newHashMap();
|
||||
@@ -72,7 +65,8 @@ public class ModelCrate implements ISmartItemModel {
|
||||
|
||||
public ModelCrate() {
|
||||
textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
|
||||
public TextureAtlasSprite apply(ResourceLocation location) {
|
||||
@Override
|
||||
public TextureAtlasSprite apply(ResourceLocation location) {
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,7 +12,10 @@ package forestry.core.models;
|
||||
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelIndex {
|
||||
|
||||
public final ModelResourceLocation modelLocation;
|
||||
|
||||
@@ -16,42 +16,48 @@ import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IRegistry;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelManager implements IModelManager {
|
||||
|
||||
private static final ModelManager instance = new ModelManager();
|
||||
|
||||
private static final ArrayList<BlockModelIndex> customBlockModels = new ArrayList<BlockModelIndex>();
|
||||
private static final ArrayList<ModelIndex> customModels = new ArrayList<ModelIndex>();
|
||||
|
||||
private static ModelManager instance;
|
||||
static {
|
||||
ForestryAPI.modelManager = instance;
|
||||
}
|
||||
|
||||
public static ModelManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ModelManager();
|
||||
ForestryAPI.modleManager = instance;
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemModel(Item item, int meta, String identifier) {
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, getModelLocation(item, identifier));
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, getModelLocation(identifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemModel(Item item, int meta, String modID, String identifier) {
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, getModelLocation(item, modID, identifier));
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, getModelLocation(modID, identifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,11 +79,39 @@ public class ModelManager implements IModelManager {
|
||||
ModelBakery.registerItemVariants(item, resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, int meta) {
|
||||
return getModelLocation(StringUtil.cleanItemName(new ItemStack(item, 1, meta)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, int meta, String identifier) {
|
||||
return getModelLocation(StringUtil.cleanTags(item.getUnlocalizedName(new ItemStack(item, 1, meta))) + identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item) {
|
||||
return getModelLocation(StringUtil.cleanItemName(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(String identifier) {
|
||||
return getModelLocation(Constants.ID, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(String modID, String identifier) {
|
||||
return new ModelResourceLocation(modID + ":" + identifier, "inventory");
|
||||
}
|
||||
|
||||
public static void registerModels() {
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof IItemModelRegister) {
|
||||
((IItemModelRegister) block).registerModel(Item.getItemFromBlock(block), getInstance());
|
||||
}
|
||||
if (block instanceof IStateMapperRegister) {
|
||||
((IStateMapperRegister) block).registerStateMapper();
|
||||
}
|
||||
}
|
||||
for (Item item : GameData.getItemRegistry()) {
|
||||
if (item instanceof IItemModelRegister) {
|
||||
@@ -85,61 +119,25 @@ public class ModelManager implements IModelManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerStateMappers(){
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof IStateMapperRegister) {
|
||||
((IStateMapperRegister) block).registerStateMapper();
|
||||
}
|
||||
|
||||
public static void registerCustomModels(ModelBakeEvent event) {
|
||||
IRegistry registry = event.modelRegistry;
|
||||
for (final BlockModelIndex index : customBlockModels) {
|
||||
registry.putObject(index.blockModelLocation, index.model);
|
||||
registry.putObject(index.itemModelLocation, index.model);
|
||||
}
|
||||
|
||||
for (final ModelIndex index : customModels) {
|
||||
registry.putObject(index.modelLocation, index.model);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(String identifier) {
|
||||
return new ModelResourceLocation("forestry:" + identifier, "inventory");
|
||||
|
||||
public static void registerCustomBlockModel(@Nonnull BlockModelIndex index){
|
||||
customBlockModels.add(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(String modID, String identifier) {
|
||||
return new ModelResourceLocation(modID + ":" + identifier, "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, int meta) {
|
||||
return new ModelResourceLocation(
|
||||
"forestry:" + StringUtil.cleanItemName(new ItemStack(item, 1, meta)), "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, int meta, String identifier) {
|
||||
return new ModelResourceLocation(
|
||||
"forestry:" + StringUtil.cleanTags(item.getUnlocalizedName(new ItemStack(item, 1, meta))) + identifier,
|
||||
"inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, int meta, String modifier, String identifier) {
|
||||
return new ModelResourceLocation("forestry:" + modifier + "/" + identifier, "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item) {
|
||||
return new ModelResourceLocation("forestry:" + StringUtil.cleanItemName(item), "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, String identifier) {
|
||||
return new ModelResourceLocation("forestry:" + identifier, "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(Item item, String modID, String identifier) {
|
||||
return new ModelResourceLocation(modID + ":" + identifier, "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelBaker createNewRenderer() {
|
||||
return new ModelBaker();
|
||||
|
||||
public static void registerCustomModel(@Nonnull ModelIndex index){
|
||||
customModels.add(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +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.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.util.IRegistry;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
|
||||
public class RenderHandler {
|
||||
|
||||
public static final ArrayList<BlockModelIndex> blockModels = new ArrayList<BlockModelIndex>();
|
||||
public static final ArrayList<ModelIndex> models = new ArrayList<ModelIndex>();
|
||||
|
||||
public static void registerModels(ModelBakeEvent event) {
|
||||
IRegistry registry = event.modelRegistry;
|
||||
for (final BlockModelIndex index : blockModels) {
|
||||
registry.putObject(index.blockModelLocation, index.model);
|
||||
registry.putObject(index.itemModelLocation, index.model);
|
||||
}
|
||||
|
||||
for (final ModelIndex index : models) {
|
||||
registry.putObject(index.modelLocation, index.model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+15
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
package forestry.core.models.baker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -28,11 +29,24 @@ import net.minecraft.client.resources.model.ModelRotation;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.IColoredBakedQuad;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A model baker to make custom models in the mod
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelBaker implements IModelBaker {
|
||||
|
||||
private static final ModelBaker instance = new ModelBaker();
|
||||
|
||||
static {
|
||||
ForestryAPI.modelBaker = instance;
|
||||
}
|
||||
|
||||
public static ModelBaker getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected double renderMinX;
|
||||
protected double renderMaxX;
|
||||
+7
-1
@@ -8,13 +8,19 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
package forestry.core.models.baker;
|
||||
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A face of a baked model
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelBakerFace {
|
||||
|
||||
public final EnumFacing face;
|
||||
+4
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
package forestry.core.models.baker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,7 +22,10 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelBakerModel implements IBakedModel {
|
||||
protected List<BakedQuad>[] faces = new List[6];
|
||||
protected List<BakedQuad> general;
|
||||
@@ -70,8 +70,8 @@ public class PacketFXSignal extends PacketCoordinates implements IForestryPacket
|
||||
super.writeData(data);
|
||||
data.writeShort(visualFX.ordinal());
|
||||
data.writeShort(soundFX.ordinal());
|
||||
data.writeUTF(ItemStackUtil.getBlockNameFromRegistryAsSting(state.getBlock()));
|
||||
data.writeInt(state.getBlock().getMetaFromState(state));
|
||||
data.writeUTF(ItemStackUtil.getBlockNameFromRegistryAsSting(state.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.b3d.B3DLoader;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.ModelIndex;
|
||||
|
||||
@@ -34,6 +34,8 @@ import net.minecraftforge.client.model.b3d.B3DLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.apiculture.entities.EntityFXBee;
|
||||
import forestry.apiculture.render.ParticleRenderer;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
@@ -46,7 +48,6 @@ import forestry.core.fluids.Fluids;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.models.RenderHandler;
|
||||
import forestry.core.render.RenderAnalyzer;
|
||||
import forestry.core.render.RenderEscritoire;
|
||||
import forestry.core.render.RenderMachine;
|
||||
@@ -120,8 +121,8 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockModel(final BlockModelIndex index) {
|
||||
RenderHandler.blockModels.add(index);
|
||||
public void registerBlockModel(@Nonnull BlockModelIndex index) {
|
||||
ModelManager.registerCustomBlockModel(index);
|
||||
StateMapperBase ignoreState = new StateMapperBase() {
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) {
|
||||
@@ -132,8 +133,8 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(final ModelIndex index) {
|
||||
RenderHandler.models.add(index);
|
||||
public void registerModel(@Nonnull ModelIndex index) {
|
||||
ModelManager.registerCustomModel(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +170,6 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelManager.registerStateMappers();
|
||||
ModelManager.registerModels();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forestry.core.render;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockStateBase;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.blocks.BlockBase;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.energy.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.blocks.IBlockType;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import javax.annotation.Nullable;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
@@ -99,7 +97,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Rectangle> getGuiExtraAreas(GuiForestry guiContainer) {
|
||||
GuiForestry<?,?> guiForestry = (GuiForestry<?,?>) guiContainer;
|
||||
GuiForestry<?,?> guiForestry = guiContainer;
|
||||
return guiForestry.getExtraGuiAreas();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.lepidopterology.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@@ -10,13 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.lepidopterology.proxy;
|
||||
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.lepidopterology.entities.EntityButterfly;
|
||||
import forestry.lepidopterology.render.ModelButterflyItem;
|
||||
import forestry.lepidopterology.render.RenderButterflyEntity;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class ProxyLepidopterologyClient extends ProxyLepidopterology {
|
||||
|
||||
@@ -18,10 +18,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.models.TRSRBakedModel;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
package forestry.mail.blocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import forestry.core.blocks.IBlockType;
|
||||
import forestry.core.blocks.IMachineProperties;
|
||||
import forestry.core.blocks.MachineProperties;
|
||||
|
||||
@@ -56,7 +56,8 @@ import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.AlleleRegistry;
|
||||
import forestry.core.items.EnumContainerType;
|
||||
import forestry.core.items.ItemRegistryCore;
|
||||
import forestry.core.models.RenderHandler;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.models.baker.ModelBaker;
|
||||
import forestry.core.multiblock.MultiblockLogicFactory;
|
||||
import forestry.core.network.IPacketRegistry;
|
||||
import forestry.core.network.PacketRegistryCore;
|
||||
@@ -96,6 +97,9 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
AlleleHelper.instance = new AlleleHelper();
|
||||
|
||||
MultiblockManager.logicFactory = new MultiblockLogicFactory();
|
||||
|
||||
//To crate the ModelBaker
|
||||
ModelBaker.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -346,6 +350,6 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onBakeModel(ModelBakeEvent event) {
|
||||
RenderHandler.registerModels(event);
|
||||
ModelManager.registerCustomModels(event);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user