Jump to content

Porting from 1.8 to 1.10.2 -- ModelBakery changed


kreezxil

Recommended Posts

I see that the ModelBakery changed so that the method "addVariantName" no longer exists. I've poking around the code and available resources and I am not sure what to use in place of the "addVariantName" method. From what I can tell, what used to be a simple one-liner is now going to be at least 10 additional lines. But I'm still unsure as to where to go. What are the suggestions and is there a new resource for discovering how to do these things in 1.10.2?

 

My code style is reminiscent of BedrockMiner's from http://BedrockMiner.jimdo.com as I used his tutorials to initially create the mod. However, he states on his front page that he is no longer continuing the tutorial project and so 1.8 is the highest he has gone before giving up on it (I hope temporarily).

 

The function with my code that is no longer valid

 

	public static void ovenRack(Block block, int maxTier) {
	String[] names = new String[maxTier];
	for (int i = 0; i < maxTier; i++) {
		names[i] = modid + ":" + tiers[i]
				+ block.getUnlocalizedName().substring(5);
	}

	//this is no longer valid in 1.10.2
                ModelBakery.addVariantName(Item.getItemFromBlock(block), names);
}

 

 

For context this comes from my BlockRenderRegister.java

 

package com.kreezxil.compressedblocks.client.render.blocks;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;

import com.kreezxil.compressedblocks.CompressedBlocks;
import com.kreezxil.compressedblocks.ModBlocks;

public class BlockRenderRegister {

public static String modid = CompressedBlocks.MODID;
public static String[] tiers = { "", "Double", "Triple", "Quadruple",
		"Quintuple", "Sextuple", "Septuple", "Octuple" };

public static void blockReg(Block block) {
	Minecraft
			.getMinecraft()
			.getRenderItem()
			.getItemModelMesher()
			.register(
					Item.getItemFromBlock(block),
					0,
					new ModelResourceLocation(modid + ":"
							+ block.getUnlocalizedName().substring(5),
							"inventory"));
}

public static void blockReg(Block block, int state, String name) {
	Minecraft
			.getMinecraft()
			.getRenderItem()
			.getItemModelMesher()
			.register(
					Item.getItemFromBlock(block),
					state,
					new ModelResourceLocation(modid + ":" + name,
							"inventory"));
}

public static void stateReg(Block block, int maxTier) {
	for (int state = 0; state < maxTier; state++) {
		blockReg(block, state, tiers[state]
				+ block.getUnlocalizedName().substring(5));
	}
}

public static void registerBlockRenderer() {
	blockReg(ModBlocks.ActivatedCarbonite);
	blockReg(ModBlocks.coalAndGravelMix);

	stateReg(ModBlocks.CompressedCobblestone, ;
	stateReg(ModBlocks.CompressedDirt, ;
	stateReg(ModBlocks.CompressedGravel, ;
	stateReg(ModBlocks.CompressedSand, ;
	stateReg(ModBlocks.CompressedRedSand, ;
	stateReg(ModBlocks.CompressedFlint, ;
	stateReg(ModBlocks.CompressedCoalBlock, 4);
	stateReg(ModBlocks.CompressedEnder_Pearl,;
	stateReg(ModBlocks.CompressedIron,;
	stateReg(ModBlocks.CompressedLapis,;
	stateReg(ModBlocks.CompressedNetherrack,;
	stateReg(ModBlocks.CompressedDiamond,;
	stateReg(ModBlocks.CompressedEmerald,;
	stateReg(ModBlocks.CompressedEnd_Stone,;
	stateReg(ModBlocks.CompressedGold,;
	stateReg(ModBlocks.CompressedClay,;
	stateReg(ModBlocks.CompressedObsidian,;
	stateReg(ModBlocks.CompressedRedstone,;
}

public static void ovenRack(Block block, int maxTier) {
	String[] names = new String[maxTier];
	for (int i = 0; i < maxTier; i++) {
		names[i] = modid + ":" + tiers[i]
				+ block.getUnlocalizedName().substring(5);
	}
	ModelBakery.addVariantName(Item.getItemFromBlock(block), names);
}

public static void preInit() {

	ovenRack(ModBlocks.CompressedCobblestone, ;
	ovenRack(ModBlocks.CompressedDirt, ;
	ovenRack(ModBlocks.CompressedGravel, ;
	ovenRack(ModBlocks.CompressedSand, ;
	ovenRack(ModBlocks.CompressedRedSand, ;
	ovenRack(ModBlocks.CompressedFlint, ;
	ovenRack(ModBlocks.CompressedCoalBlock, 4);
	ovenRack(ModBlocks.CompressedEnder_Pearl,;
	ovenRack(ModBlocks.CompressedIron,;
	ovenRack(ModBlocks.CompressedLapis,;
	ovenRack(ModBlocks.CompressedNetherrack,;
	ovenRack(ModBlocks.CompressedDiamond,;
	ovenRack(ModBlocks.CompressedEmerald,;
	ovenRack(ModBlocks.CompressedEnd_Stone,;
	ovenRack(ModBlocks.CompressedGold,;
	ovenRack(ModBlocks.CompressedClay,;
	ovenRack(ModBlocks.CompressedObsidian,;
	ovenRack(ModBlocks.CompressedRedstone,;
}
}

 

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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