Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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,;
}
}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.