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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • What MC version? What's the IP? Are any mods needed to be able to join?
    • Thank you for your answer ! Unfortunatly i have the same problem when i use setPos() public static int movingfunction(CommandContext<CommandSourceStack> context){ CommandSourceStack source = context.getSource(); if (!(source.getEntity() instanceof ServerPlayer)) { return 0; } ServerPlayer player = (ServerPlayer ) source.getEntity(); double moveSpeed = 0.5; for (int i =0; i<10000;i++) { LOGGER.info("running for the {} time", i); double x = player.getX() + player.getViewVector(1.0f).x * moveSpeed; double y = player.getY(); double z = player.getZ() + player.getViewVector(1.0f).z * moveSpeed ; Vec3 movementVec = new Vec3(x, y, z); LOGGER.info("x ={} y ={} z ={}", x, y, z); player.setPos( movementVec); } return 1; } With the logs i can see that x and z are increasing but once again my player is not moving. is there a function to use to sync the server and the client ? I also tried to use LocalPlayer instead of ServerPlayer but my code would stop when i got the object. Also i will change a bit the main topic but is there a way to similate key press ? i found KeyBinding.setKeyBindState on others post but it look like there is no more KeyBinding in 1.20   I found this code : KeyMapping.click(Minecraft.getInstance().options.keyUp.getKey()); But it doesn't seems to work   And i found this one : Minecraft.getInstance().options.keyUp.setDown(true); wich works but doesn't exactly do what i want , it doesn't release the key so for exemple i can't make him run. Minecraft.getInstance().options.keyUp.setDown(true); Minecraft.getInstance().options.keyUp.setDown(false); Minecraft.getInstance().options.keyUp.setDown(true); doesn't make him run
    • Add crash-reports with sites like https://paste.ee/ Maybe an issue with blur, essentials or cumulus_menus
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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