Jump to content

Recommended Posts

Posted (edited)

Iv'e been trying to figure out how to change the texture of model elements independently, I followed TheGreyGhost's tutorial I'm moderately experienced at modding but, I haven't found many tutorials on how Imodels work or how to use the retexture method, Iv'e got the base model working, now I need the elements around the core to change texture depending on an int value, the int values will be set by the blocks around it. Also would I need it to be a tile entity if I want it to keep the texture changes? here is what I have so far

Block

import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import omni.crystals.block.LinkBlock;

public class Core2Block extends LinkBlock
{
	public static final IUnlistedProperty<Boolean> LINK_NORTH = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_north"));
	public static final IUnlistedProperty<Boolean> LINK_SOUTH = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_south"));
	public static final IUnlistedProperty<Boolean> LINK_WEST = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_west"));
	public static final IUnlistedProperty<Boolean> LINK_EAST = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_east"));
	public static final IUnlistedProperty<Boolean> LINK_UP = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_up"));
	public static final IUnlistedProperty<Boolean> LINK_DOWN = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_down"));
	public static final IUnlistedProperty<Boolean> LINK_X = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_x"));
	public static final IUnlistedProperty<Boolean> LINK_Y = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_y"));
	public static final IUnlistedProperty<Boolean> LINK_Z = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("link_z"));
	public static boolean linknorth;
	public static boolean linksouth;
	public static boolean linkwest;
	public static boolean linkeast;
	public static boolean linkup;
	public static boolean linkdown;
	public static boolean linkx = true;
	public static boolean linky = true;
	public static boolean linkz = true;
	public static int NWD;
	public static int ND;
	public static int NED;
	public static int WD;
	public static int D = 6;
	public static int ED;
	public static int SWD;
	public static int SD;
	public static int SED;
	public static int NW;
	public static int N = 6;
	public static int NE;
	public static int W = 6;
	public static int E = 6;
	public static int SW;
	public static int S = 6;
	public static int SE;
	public static int NWU;
	public static int NU;
	public static int NEU;
	public static int WU;
	public static int U = 6;
	public static int EU;
	public static int SWU;
	public static int SU;
	public static int SEU;
	public Core2Block(String name, Material material, float Hardness, float resistance, int energy)
	{
		super(name, material, Hardness, resistance, energy);
	}
	@SideOnly(Side.CLIENT)
	public BlockRenderLayer getBlockLayer()
	{
		return BlockRenderLayer.SOLID;
	}
	@Override
	public boolean isOpaqueCube(IBlockState blockState)
	{
		return false;
	}
	@Override
	public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
	{
	}
	@Override
	public boolean isFullCube(IBlockState blockState)
	{
		return false;
	}
	@Override
	public EnumBlockRenderType getRenderType(IBlockState iBlockState)
	{
		return EnumBlockRenderType.MODEL;
	}
	@Override
	protected BlockStateContainer createBlockState()
	{
		IProperty [] listedProperties = new IProperty[0];
		IUnlistedProperty [] unlistedProperties = new IUnlistedProperty[] {LINK_NORTH, LINK_SOUTH, LINK_EAST, LINK_WEST, LINK_UP, LINK_DOWN, LINK_X, LINK_Y, LINK_Z};
		return new ExtendedBlockState(this, listedProperties, unlistedProperties);
	}
	@Override
	public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
	{
		if (state instanceof IExtendedBlockState)
		{  // avoid crash in case of mismatch
			IExtendedBlockState retval = (IExtendedBlockState)state;
			retval = retval.withProperty(LINK_NORTH, linknorth);
			retval = retval.withProperty(LINK_SOUTH, linksouth);
			retval = retval.withProperty(LINK_EAST, linkeast);
			retval = retval.withProperty(LINK_WEST, linkwest);
			retval = retval.withProperty(LINK_UP, linkup);
			retval = retval.withProperty(LINK_DOWN, linkdown);
			retval = retval.withProperty(LINK_X, linkx);
			retval = retval.withProperty(LINK_Y, linky);
			retval = retval.withProperty(LINK_Z, linkz);
			return retval;
		}
		return state;
	}
}

 

 compositemodel


import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.IPerspectiveAwareModel;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import org.apache.commons.lang3.tuple.Pair;

import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import java.util.LinkedList;
import java.util.List;

public class CompositeModel implements IPerspectiveAwareModel
{
	private IBakedModel modelCore;
	private IBakedModel modelNorth;
	private IBakedModel modelSouth;
	private IBakedModel modelWest;
	private IBakedModel modelEast;
	private IBakedModel modelUp;
	private IBakedModel modelDown;
	private IBakedModel modelX;
	private IBakedModel modelY;
	private IBakedModel modelZ;
	public CompositeModel(IBakedModel i_modelCore, IBakedModel i_modelNorth, IBakedModel i_modelSouth, IBakedModel i_modelWest, IBakedModel i_modelEast, IBakedModel i_modelUp, IBakedModel i_modelDown, IBakedModel i_modelX, IBakedModel i_modelY, IBakedModel i_modelZ)
	{
		modelCore = i_modelCore;
		modelNorth = i_modelNorth;
		modelSouth = i_modelSouth;
		modelWest = i_modelWest;
		modelEast = i_modelEast;
		modelUp = i_modelUp;
		modelDown = i_modelDown;
		modelX = i_modelX;
		modelY = i_modelY;
		modelZ = i_modelZ;
	}
	/**
	 * Compile a list of quads for rendering.  This is done by making a list of all the quads from the component
	 *   models, depending on which links are present.
	 * For example
	 * @param blockState
	 * @param side which side of the block is being rendered; null =
	 * @param rand
	 * @return
	 */
	@Override
	public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand)
	{
		List<BakedQuad> quadsList = new LinkedList<BakedQuad>();
		quadsList.addAll(modelCore.getQuads(blockState, side, rand));
		if (!(blockState instanceof IExtendedBlockState))
		{
			return quadsList;
		}
		IExtendedBlockState extendedBlockState = (IExtendedBlockState)blockState;
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_NORTH))
		{
			quadsList.addAll(modelNorth.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_SOUTH))
		{
			quadsList.addAll(modelSouth.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_WEST))
		{
			quadsList.addAll(modelWest.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_EAST))
		{
			quadsList.addAll(modelEast.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_UP))
		{
			quadsList.addAll(modelUp.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_DOWN))
		{
			quadsList.addAll(modelDown.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_X))
		{
			quadsList.addAll(modelX.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_Y))
		{
			quadsList.addAll(modelY.getQuads(extendedBlockState, side, rand));
		}
		if (isLinkPresent(extendedBlockState, Core2Block.LINK_Z))
		{
			quadsList.addAll(modelZ.getQuads(extendedBlockState, side, rand));
		}
		return quadsList;
	}
	@Override
	public boolean isAmbientOcclusion()
	{
		return modelCore.isAmbientOcclusion();
	}
	@Override
	public boolean isGui3d()
	{
		return modelCore.isGui3d();
	}
	@Override
	public boolean isBuiltInRenderer()
	{
		return false;
	}
	// used for block breaking shards
	@Override
	public TextureAtlasSprite getParticleTexture()
	{
		TextureAtlasSprite textureAtlasSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("crystal:blocks/crysidian");
		return textureAtlasSprite;
	}
	@Override
	public ItemCameraTransforms getItemCameraTransforms()
	{
		return modelCore.getItemCameraTransforms();
	}
	/** this method is necessary because Forge has deprecated getItemCameraTransforms(), and modelCore.getItemCameraTransforms()
	 *    may not return anything meaningful.  But if the base model doesn't implement IPerspectiveAwareModel then you
	 *    need to generate it.
	 * @param cameraTransformType
	 * @return
	 */
	@Override
	public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
	{
		if (modelCore instanceof IPerspectiveAwareModel)
		{
			Matrix4f matrix4f = ((IPerspectiveAwareModel)modelCore).handlePerspective(cameraTransformType).getRight();
			return Pair.of(this, matrix4f);
		}
		else
		{
			// If the parent model isn't an IPerspectiveAware, we'll need to generate the correct matrix ourselves using the
			//  ItemCameraTransforms.
			ItemCameraTransforms itemCameraTransforms = modelCore.getItemCameraTransforms();
			ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
			TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
			Matrix4f mat = null;
			if (tr != null)
			{ 
				mat = tr.getMatrix();
			}
			// The TRSRTransformation for vanilla items have blockCenterToCorner() applied, however handlePerspective
			//  reverses it back again with blockCornerToCenter().  So we don't need to apply it here.

			return Pair.of(this, mat);
		}
	}
	@Override
	public ItemOverrideList getOverrides()
	{
		return null;
	}
	private boolean isLinkPresent(IExtendedBlockState iExtendedBlockState, IUnlistedProperty<Boolean> whichLink)
	{
		Boolean link = iExtendedBlockState.getValue(whichLink);
		if (link == null)
		{
			return false;
		}
		return link;
	}
}

Model

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.IRetexturableModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.fluids.Fluid;

import java.util.Collection;

import javax.annotation.Nullable;

/**
 * Created by TheGreyGhost on 22/04/2015.
 * WebModel is an intermediate step between the ModelResourceLocation and the final IBakedModel.
 * In this case, our IModel has a number of dependant sub-components.  We bake them all individually and store them
 *   in the CompositeModel.
 * Each of the submodels needs to be loaded by vanilla as a block model which means we need a blockstates file for each of them.
 *   see blockstates/mbe05_web_subblocks
 */
public class Core2Model implements IModel, IRetexturableModel
{
	public static final ResourceLocation TEXTURE_CORE = new ResourceLocation("crystal:blocks/crysidian");
	public static final ResourceLocation TEXTURE_RED = new ResourceLocation("crystal:blocks/crystal_red");
	public static final ResourceLocation TEXTURE_ORANGE = new ResourceLocation("crystal:blocks/crystal_orange");
	public static final ResourceLocation TEXTURE_YELLOW = new ResourceLocation("crystal:blocks/crystal_yellow");
	public static final ResourceLocation TEXTURE_GREEN = new ResourceLocation("crystal:blocks/crystal_green");
	public static final ResourceLocation TEXTURE_BLUE = new ResourceLocation("crystal:blocks/crystal_blue");
	public static final ResourceLocation TEXTURE_INDIGO = new ResourceLocation("crystal:blocks/crystal_indigo");
	public static final ResourceLocation TEXTURE_PURPLE = new ResourceLocation("crystal:blocks/crystal_purple");
	public static final ModelResourceLocation MODEL_CORE = new ModelResourceLocation("crystal:crystal_core");
	public static final ModelResourceLocation MODEL_NORTH = new ModelResourceLocation("crystal:core_link_north");
	public static final ModelResourceLocation MODEL_SOUTH = new ModelResourceLocation("crystal:core_link_south");
	public static final ModelResourceLocation MODEL_WEST = new ModelResourceLocation("crystal:core_link_west");
	public static final ModelResourceLocation MODEL_EAST = new ModelResourceLocation("crystal:core_link_east");
	public static final ModelResourceLocation MODEL_UP = new ModelResourceLocation("crystal:core_link_up");
	public static final ModelResourceLocation MODEL_DOWN = new ModelResourceLocation("crystal:core_link_down");
	public static final ModelResourceLocation MODEL_X = new ModelResourceLocation("crystal:core_link_x");
	public static final ModelResourceLocation MODEL_Y = new ModelResourceLocation("crystal:core_link_y");
	public static final ModelResourceLocation MODEL_Z = new ModelResourceLocation("crystal:core_link_z");

	@Nullable
	public final ResourceLocation NWD;
	@Nullable
	public final ResourceLocation ND;
	@Nullable
	public final ResourceLocation NED;
	@Nullable
	public final ResourceLocation WD;
	@Nullable
	public final ResourceLocation D;
	@Nullable
	public final ResourceLocation ED;
	@Nullable
	public final ResourceLocation SWD;
	@Nullable
	public final ResourceLocation SD;
	@Nullable
	public final ResourceLocation SED;
	@Nullable
	public final ResourceLocation NW;
	@Nullable
	public final ResourceLocation N;
	@Nullable
	public final ResourceLocation NE;
	@Nullable
	public final ResourceLocation W;
	@Nullable
	public final ResourceLocation E;
	@Nullable
	public final ResourceLocation SW;
	@Nullable
	public final ResourceLocation S;
	@Nullable
	public final ResourceLocation SE;
	@Nullable
	public final ResourceLocation NWU;
	@Nullable
	public final ResourceLocation NU;
	@Nullable
	public final ResourceLocation NEU;
	@Nullable
	public final ResourceLocation WU;
	@Nullable
	public final ResourceLocation U;
	@Nullable
	public final ResourceLocation EU;
	@Nullable
	public final ResourceLocation SWU;
	@Nullable
	public final ResourceLocation SU;
	@Nullable
	public final ResourceLocation SEU;
	public Core2Model()
	{
		this(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
	}
	public Core2Model(@Nullable ResourceLocation l1, @Nullable ResourceLocation l2, @Nullable ResourceLocation l3, @Nullable ResourceLocation l4, @Nullable ResourceLocation l5, @Nullable ResourceLocation l6, @Nullable ResourceLocation l7, @Nullable ResourceLocation l8, @Nullable ResourceLocation l9, @Nullable ResourceLocation l10, @Nullable ResourceLocation l11, @Nullable ResourceLocation l12, @Nullable ResourceLocation l13, @Nullable ResourceLocation l14, @Nullable ResourceLocation l15, @Nullable ResourceLocation l16, @Nullable ResourceLocation l17, @Nullable ResourceLocation l18, @Nullable ResourceLocation l19, @Nullable ResourceLocation l20, @Nullable ResourceLocation l21, @Nullable ResourceLocation l22, @Nullable ResourceLocation l23, @Nullable ResourceLocation l24, @Nullable ResourceLocation l25, @Nullable ResourceLocation l26)
	{
		this.NWD = l1; this.ND = l2; this.NED = l3; this.WD = l4; this.D = l5; this.ED = l6; this.SWD = l7; this.SD = l8;
		this.SED = l9; this.NW = l10; this.N = l11; this.NE = l12; this.W = l13; this.E = l14; this.SW = l15; this.S = l16;
		this.SE = l17; this.NWU = l18; this.NU = l19; this.NEU = l20; this.WU = l21; this.U = l22; this.EU = l23; this.SWU = l24;
		this.SU = l25; this.SEU = l26;
	}
	// return all other resources used by this model (not strictly needed for this example because we load all the subcomponent
	//   models during the bake anyway)
	@Override
	public Collection<ResourceLocation> getDependencies()
	{
		return ImmutableList.copyOf(new ResourceLocation[]{MODEL_CORE, MODEL_WEST, MODEL_EAST, MODEL_NORTH, MODEL_SOUTH, MODEL_UP, MODEL_DOWN, MODEL_X, MODEL_Y, MODEL_Z});
	}
	// return all the textures used by this model (not strictly needed for this example because we load all the subcomponent
	//   models during the bake anyway)
	@Override
	public Collection<ResourceLocation> getTextures()
	{
		return ImmutableList.copyOf(new ResourceLocation[]{TEXTURE_CORE, TEXTURE_RED, TEXTURE_ORANGE, TEXTURE_YELLOW, TEXTURE_GREEN, TEXTURE_BLUE, TEXTURE_INDIGO, TEXTURE_PURPLE});
	}
	//  Bake the subcomponents into a CompositeModel
	@Override
	public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
	{
		try
		{
			IModel subComponent = ModelLoaderRegistry.getModel(MODEL_CORE);
			IBakedModel bakedModelCore = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_NORTH);
			IBakedModel bakedModelNorth = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_SOUTH);
			IBakedModel bakedModelSouth = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_WEST);
			IBakedModel bakedModelWest = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_EAST);
			IBakedModel bakedModelEast = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_UP);
			IBakedModel bakedModelUp = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_DOWN);
			IBakedModel bakedModelDown = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_X);
			IBakedModel bakedModelX = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_Y);
			IBakedModel bakedModelY = subComponent.bake(state, format, bakedTextureGetter);
			subComponent = ModelLoaderRegistry.getModel(MODEL_Z);
			IBakedModel bakedModelZ = subComponent.bake(state, format, bakedTextureGetter);

			return new CompositeModel(bakedModelCore, bakedModelNorth, bakedModelSouth, bakedModelWest, bakedModelEast, bakedModelUp, bakedModelDown, bakedModelX, bakedModelY, bakedModelZ);
		}
		catch (Exception exception)
		{
			System.err.println("Core2Model.bake() failed due to exception:" + exception);
			return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
		}
	}
	// Our custom loaded doesn't need a default state, just return null
	@Override
	public IModelState getDefaultState()
	{
		return null;
	}
	@Override
	public IModel retexture(ImmutableMap<String, String> textures)
	{
		ResourceLocation nwd = NWD;
		ResourceLocation nd = ND;
		ResourceLocation ned = NED;
		ResourceLocation wd = WD;
		ResourceLocation d = D;
		ResourceLocation ed = ED;
		ResourceLocation swd = SWD;
		ResourceLocation sd = SD;
		ResourceLocation sed = SED;
		ResourceLocation nw = NW;
		ResourceLocation n = N;
		ResourceLocation ne = NE;
		ResourceLocation w = W;
		ResourceLocation e = E;
		ResourceLocation sw = SW;
		ResourceLocation s = S;
		ResourceLocation se = SE;
		ResourceLocation nwu = NWU;
		ResourceLocation nu = NU;
		ResourceLocation neu = NEU;
		ResourceLocation wu = WU;
		ResourceLocation u = U;
		ResourceLocation eu = EU;
		ResourceLocation swu = SWU;
		ResourceLocation su = SU;
		ResourceLocation seu = SEU;
		ResourceLocation[] texs = new ResourceLocation[]{nwd,nd,ned,wd,d,ed,swd,sd,sed,nw,n,ne,w,e,sw,s,se,nwu,nu,neu,wu,u,eu,swu,su,seu};
		String[] links = new String[]{"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25"};
		int[] locs = new int[]{Core2Block.NWD,Core2Block.ND,Core2Block.NED,Core2Block.WD,Core2Block.D,Core2Block.ED,Core2Block.SWD,Core2Block.SD,Core2Block.SED,Core2Block.NW,Core2Block.N,Core2Block.NE,Core2Block.W,Core2Block.E,Core2Block.SW,Core2Block.S,Core2Block.SE,Core2Block.NWU,Core2Block.NU,Core2Block.NEU,Core2Block.WU,Core2Block.U,Core2Block.EU,Core2Block.SWU,Core2Block.SU,Core2Block.SEU};
		for(String link : links)
		{
			for(int loc : locs)
			{
				for(ResourceLocation tex : texs)
				{
					if (textures.containsKey(link))
					{
						if(loc == 0){tex = TEXTURE_RED;}
						if(loc == 1){tex = TEXTURE_ORANGE;}
						if(loc == 2){tex = TEXTURE_YELLOW;}
						if(loc == 3){tex = TEXTURE_GREEN;}
						if(loc == 4){tex = TEXTURE_BLUE;}
						if(loc == 5){tex = TEXTURE_INDIGO;}
						if(loc == 6){tex = TEXTURE_PURPLE;}
					}
				}
			}
		}
		return new Core2Model(nwd, nd, ned, wd, d, ed, swd, sd, sed, nw, n, ne, w, e, sw, s, se, nwu, nu, neu, wu, u, eu, swu, su, seu);
	}
}

ModelLoader

import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;

/**
 * Created by TheGreyGhost on 19/04/2015.
 * The ModelLoader3DWeb is used to "load" the Block3D's model instead of the Vanilla loader looking for a .json file
 *
 */
public class ModelLoaderCore2 implements ICustomModelLoader
{
  public final String SMART_MODEL_RESOURCE_LOCATION = "models/block/smartmodel/";

  // return true if our Model Loader accepts this ModelResourceLocation
  @Override
  public boolean accepts(ResourceLocation resourceLocation)
  {
    return resourceLocation.getResourceDomain().equals("crystal") && resourceLocation.getResourcePath().startsWith(SMART_MODEL_RESOURCE_LOCATION);
  }
  // When called for our Block3DWeb's ModelResourceLocation, return our WebModel.
  @Override
  public IModel loadModel(ResourceLocation resourceLocation)
  {
    String resourcePath = resourceLocation.getResourcePath();
    if (!resourcePath.startsWith(SMART_MODEL_RESOURCE_LOCATION))
    {
      assert false : "loadModel expected " + SMART_MODEL_RESOURCE_LOCATION + " but found " + resourcePath;
    }
    String modelName = resourcePath.substring(SMART_MODEL_RESOURCE_LOCATION.length());
    if (modelName.equals("coremodel"))
    {
      return new Core2Model();
    }
    else
    {
      return ModelLoaderRegistry.getMissingModel();
    }
  }
  // don't need it for this example; you might.  We have to implement it anyway.
  @Override
  public void onResourceManagerReload(IResourceManager resourceManager)
  {
    this.resourceManager = resourceManager;
  }
  private IResourceManager resourceManager;
}

any help is greatly appreciated!!!

Edited by Maurice753

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • That is incorrect. Use the run.bat or run.sh to run the server.
    • Hello, I have been trying for days to create my server with forge-1.20.1-47.4.1-installer, which installs the server, but the forge-1.20.1-47.4.1.jar file, which is necessary to create the server, does not appear. I no longer know what to do. Help. hola buenas, llevo dias intentando poder hacer mi servidor con forge-1.20.1-47.4.1-installer el cual instalo el server, pero no aparece el archivo forge-1.20.1-47.4.1.jar , el cual es necesario para poder crear el server, ya no se que hacer ayuda.
    • Does this happen if you use the regular vanilla minecraft launcher? Also, unsure if TLauncher ever has a legit usage, as I have always seen it associated with software piracy, but if it has a legit mode, make sure it is using online mode so that it can authenticate your MS account to login. Aside from that, more information is likely needed. Post logs, as well as the paths you are placing files in (screenshots of your file explorer can be helpful as well).
    • I am using a third-party launcher that has pre-installed forge versions of Minecraft.  When I insert mods from CurseForge, I extract the files and as expected put them in the .mods folder. I am guessing that there is an error with the file transfer but I don't know for sure and sometimes I use Forge to test mods that I created before releasing previously on a different pc, so I don't know if it is the if it an extraction error but if are any tips or knowledge reply and I will read it. This is also will be kept on the forum for others that have the issues.
    • I make wires and i need connection 2 wires block. I have BooleanPropertys registered, but in mod loading it show Unknown the property in assets/wuntare/blockState. public static final BooleanProperty CONNECTED_NORTH = BooleanProperty.create("connected_north"); public static final BooleanProperty CONNECTED_SOUTH = BooleanProperty.create("connected_south"); public static final BooleanProperty CONNECTED_WEST = BooleanProperty.create("connected_west"); public static final BooleanProperty CONNECTED_EAST = BooleanProperty.create("connected_east"); public static final BooleanProperty CONNECTED_UP = BooleanProperty.create("connected_up"); public static final BooleanProperty CONNECTED_DOWN = BooleanProperty.create("connected_down"); public CopperWireWithoutInsulation0(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any() .setValue(CONNECTED_NORTH, false) .setValue(CONNECTED_SOUTH, false) .setValue(CONNECTED_WEST, false) .setValue(CONNECTED_EAST, false) .setValue(CONNECTED_UP, false) .setValue(CONNECTED_DOWN, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { builder.add(CONNECTED_NORTH, CONNECTED_SOUTH, CONNECTED_WEST, CONNECTED_EAST, CONNECTED_UP, CONNECTED_DOWN); } In this part blockState have problem "multipart": [ { "apply": { "model": "wuntare:block/copper_wire_without_insulation0" } }, { "when": { "connected_north": true }, "apply": { "model": "wuntare:block/copper_wire_without_insulation0_north" } },  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.