Jump to content

[1.12.2] Shift + click movement of meta items causes them to change to stack with different types


Recommended Posts

Posted (edited)

I have 10 different ores that can be smelted into 10 different ingots and I am using metadata variants for the ore blocks and also for the ingots. I set up smelting recipes and the recipes are working just fine the ores all smelt into the correct ingots, however if I shift + click the resulting ingot out of a furnace it turns into a copper ingot which is the ingot with a metadata value of 0. I'm not sure if it's something I'm missing in my ItemIngot class or something to do with the SmeltingRecipes class.

ItemIngot class:

package hazmatik.sonictech.items;

import hazmatik.sonictech.SonicTech;
import hazmatik.sonictech.init.ItemInit;
import hazmatik.sonictech.util.interfaces.IHasModel;
import hazmatik.sonictech.util.interfaces.IMetaName;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;

public class ItemIngot extends Item implements IHasModel, IMetaName
{
	private String name;
	
	public ItemIngot(String name)
	{
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(SonicTech.sonictechtab);
		
		this.name = name;
		ItemInit.ITEMS.add(this);
	}
	
	@Override
	public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) 
	{
		for(int i = 0; i < Type.METADATA_LOOKUP.length; i++)
		{
			items.add(new ItemStack(this, 1, i));
		}
	}
	
	@Override
	public String getSpecialName(ItemStack stack)
	{
		return Type.values()[stack.getItemDamage()].getName();
	}
	
	@Override
	public String getUnlocalizedName(ItemStack stack) 
	{
		return super.getUnlocalizedName() + "_" + this.getSpecialName(stack);
	}

	@Override
	public void registerModels() 
	{
		for(int i = 0; i < Type.METADATA_LOOKUP.length; i++)
		{
			SonicTech.proxy.registerVariantRenderer(this, i, "ingot_" + Type.values()[i].getName(), "inventory");
		}
	}
	
	
	public enum Type implements IStringSerializable
	{
		COPPER(0, "copper"),
		ALUMINIUM(1, "aluminium"),
		ZINC(2, "zinc"),
		TIN(3, "tin"),
		ANTIMONY(4, "antimony"),
		MOLYBDENUM(5, "molybdenum"),
		LEAD(6, "lead"),
		SILVER(7, "silver"),
		CHROMIUM(8, "chromium"),
		MAGNESIUM(9, "magnesium");
		
		private static final Type[] METADATA_LOOKUP = new Type[values().length];
		private final int metadata;
		private final String name;
		
		Type(int metadata, String name)
		{
			this.metadata=metadata;
			this.name=name;
		}
		
		public int getMetadata()
		{
			return this.metadata;
		}
		
		@Override
		public String getName() 
		{
			return this.name;
		}
		
		public static Type byMetadata(int metadata)
		{
			if(metadata < 0 || metadata >= METADATA_LOOKUP.length)
			{
				metadata = 0;
			}
			return METADATA_LOOKUP[metadata];
		}
		
		static
		{
			for(Type type: values())
			{
				METADATA_LOOKUP[type.getMetadata()] = type;
			}
		}
	}
}

and my SmeltingRecipes class:

public class SmeltingRecipes 
{	
	public static void init()
	{
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 0), new ItemStack(ItemInit.INGOT, 1, 0), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 1), new ItemStack(ItemInit.INGOT, 1, 1), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 2), new ItemStack(ItemInit.INGOT, 1, 2), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 3), new ItemStack(ItemInit.INGOT, 1, 3), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 4), new ItemStack(ItemInit.INGOT, 1, 4), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 5), new ItemStack(ItemInit.INGOT, 1, 5), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 6), new ItemStack(ItemInit.INGOT, 1, 6), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 7), new ItemStack(ItemInit.INGOT, 1, 7), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 8), new ItemStack(ItemInit.INGOT, 1, 8), 0.7f);
		GameRegistry.addSmelting(new ItemStack(BlockInit.ORE, 1, 9), new ItemStack(ItemInit.INGOT, 1, 9), 0.7f);
	}
}

 

If anyone needs to see more of my code my github repo for the project is here: https://github.com/Hazmatik/SonicTech

 

EDIT: I don't think this is particularly related to smelting cause I just noticed any shift+click moving of the ingots even between hotbar and inventory if there is already a stack of an ingot type it will change to whichever type is there.

Edited by Hazmatik
Changed title to relate better to issue
Posted

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.