Get item in hand bug

Issue description

The in hand function does not get the in hand item it wipes all nbt data and it wont get the version of a item so lets say if you have ID 33234 but then you have 7 times under that ID 33234#1, 33234#2, 33234#3, ,33234#4 and so on, so lets take my mod I just made in to acount here it means that if a user wants to clone a log they will only get the first log of the log index or the first ore from that ore index, this is a big over sight, also not not including nbt data is very out of date now and I sure a few times we mean to be getting this kind of support it's shocking we have to wait to 2x to get anything useful.

We need a fix at lest for the ID#IINDEXID please fix this but also try add the NBT data to be included in the in hand and in off hand please.

Issue comments

Submitted by Klemen on Wed, 09/12/2018 - 06:17

This is not NBT data but metadata. I will check if there is an easy implementation for this and try to implement it. May I see a picture of your whole procedure?

Sure would the metadata also get the indexed ID EG: ID#INDEX like Birch Wood log#2 right now if I give it log#2 I think that is 17#2 it will return log#0 or 17#0 I sure 17 is the log index. It might be easier just giving you the code from that section and you don't offer a full screen open and that procedure is not really able to fit in the little window

I added both code and image if I can fix the index problem with code for now please do tell :)

1

package mod.mcreator;

import java.util.Random;
import java.util.HashMap;

import net.minecraft.entity.passive.*;
import net.minecraft.client.model.*;
import net.minecraft.entity.boss.*;
import net.minecraft.creativetab.*;
import net.minecraft.world.chunk.storage.*;

import net.minecraftforge.fml.common.network.*;

import net.minecraft.server.management.*;
import net.minecraft.client.particle.*;

import net.minecraftforge.client.model.obj.*;
import net.minecraftforge.oredict.*;

import net.minecraft.client.settings.*;

import net.minecraftforge.fml.common.eventhandler.*;

import net.minecraft.client.entity.*;

import net.minecraftforge.fml.relauncher.*;
import net.minecraftforge.fml.server.*;

import net.minecraft.block.state.pattern.*;
import net.minecraft.network.*;
import net.minecraft.client.renderer.tileentity.*;
import net.minecraft.crash.*;
import net.minecraft.stats.*;
import net.minecraft.world.gen.structure.template.*;
import net.minecraft.tileentity.*;

import net.minecraftforge.fml.client.registry.*;

import net.minecraft.world.gen.*;

import net.minecraftforge.fml.common.asm.transformers.*;

import net.minecraft.enchantment.*;

import net.minecraftforge.event.entity.*;
import net.minecraftforge.fml.common.discovery.*;

import net.minecraft.command.*;
import net.minecraft.dispenser.*;

import net.minecraftforge.event.entity.item.*;

import net.minecraft.client.gui.*;
import net.minecraft.server.*;
import net.minecraft.advancements.critereon.*;
import net.minecraft.block.*;
import net.minecraft.entity.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.inventory.*;
import net.minecraft.world.gen.layer.*;

import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.fml.common.*;

import net.minecraft.pathfinding.*;

import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.fml.common.toposort.*;

import net.minecraft.client.util.*;

import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.client.model.*;

import net.minecraft.server.gui.*;

import net.minecraftforge.client.event.*;

import net.minecraft.util.*;

import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.event.world.*;

import net.minecraft.client.renderer.block.statemap.*;

import net.minecraftforge.fml.common.discovery.asm.*;

import net.minecraft.item.crafting.*;
import net.minecraft.entity.effect.*;
import net.minecraft.client.gui.achievement.*;

import net.minecraftforge.event.entity.minecart.*;

import net.minecraft.client.renderer.culling.*;

import net.minecraftforge.fml.common.versioning.*;

import net.minecraft.entity.projectile.*;

import net.minecraftforge.common.*;

import net.minecraft.util.math.*;
import net.minecraft.entity.item.*;
import net.minecraft.item.*;

import net.minecraftforge.fml.client.*;
import net.minecraftforge.fluids.*;

import net.minecraft.init.*;
import net.minecraft.advancements.*;
import net.minecraft.client.audio.*;
import net.minecraft.world.gen.feature.*;

import net.minecraftforge.fml.common.asm.*;

import net.minecraft.block.state.*;
import net.minecraft.client.renderer.*;
import net.minecraft.util.text.*;
import net.minecraft.entity.player.*;

import net.minecraftforge.fml.common.gameevent.*;

import net.minecraft.world.storage.*;
import net.minecraft.world.biome.*;
import net.minecraft.client.*;

import net.minecraftforge.common.util.*;

import net.minecraft.network.rcon.*;
import net.minecraft.profiler.*;

import net.minecraftforge.classloading.*;

import net.minecraft.village.*;
import net.minecraft.potion.*;
import net.minecraft.block.material.*;
import net.minecraft.world.*;
import net.minecraft.nbt.*;
import net.minecraft.world.gen.structure.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraft.server.integrated.*;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.entity.ai.attributes.*;

import net.minecraftforge.client.*;
import net.minecraftforge.fml.common.registry.*;

import net.minecraft.world.chunk.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.entity.monster.*;

import net.minecraftforge.event.*;

import net.minecraft.server.dedicated.*;

public class mcreator_copyMeCode {

	public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure copyMeCode!");
			return;
		}
		if (dependencies.get("x") == null) {
			System.err.println("Failed to load dependency x for procedure copyMeCode!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure copyMeCode!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z for procedure copyMeCode!");
			return;
		}
		if (dependencies.get("world") == null) {
			System.err.println("Failed to load dependency world for procedure copyMeCode!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		int x = (int) dependencies.get("x");
		int y = (int) dependencies.get("y");
		int z = (int) dependencies.get("z");
		World world = (World) dependencies.get("world");
		if (((world.getBlockState(new BlockPos((int) x, (int) (y - 1), (int) z))).getBlock() == mcreator_netherPacked.block.getDefaultState()
				.getBlock())) {
			if (((entity instanceof EntityLivingBase)
					? ((EntityPlayer) entity).inventory.hasItemStack(new ItemStack(Items.NETHER_STAR, (int) (1)))
					: false)) {
				if ((new ItemStack(((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() : null),
						(int) (1)).getItem() == new ItemStack(Items.NETHER_STAR, (int) (1)).getItem() && new ItemStack(
						((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() : null), (int) (1))
						.getMetadata() == new ItemStack(Items.NETHER_STAR, (int) (1)).getMetadata())) {
					if (entity instanceof EntityPlayer)
						((EntityPlayer) entity).inventory
								.clearMatchingItems(new ItemStack(Items.NETHER_STAR, (int) (1)).getItem(), -1, (int) 1, null);
					if (entity instanceof EntityPlayer && !world.isRemote) {
						((EntityPlayer) entity).sendStatusMessage(new TextComponentString("Nether Gods: Thank you for the free gift."), (true));
					}
					if (entity instanceof EntityLivingBase)
						((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH, (int) 30, (int) 1));
				} else if ((new ItemStack(
						((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() : null), (int) (1))
						.getItem() == new ItemStack(Blocks.AIR, (int) (1)).getItem() && new ItemStack(((entity instanceof EntityLivingBase)
						? ((EntityLivingBase) entity).getHeldItemMainhand().getItem()
						: null), (int) (1)).getMetadata() == new ItemStack(Blocks.AIR, (int) (1)).getMetadata())) {
					if (entity instanceof EntityPlayer)
						((EntityPlayer) entity).inventory
								.clearMatchingItems(new ItemStack(Items.NETHER_STAR, (int) (1)).getItem(), -1, (int) 1, null);
					if (entity instanceof EntityPlayer && !world.isRemote) {
						((EntityPlayer) entity).sendStatusMessage(new TextComponentString("Nether Gods: Thank you for the free gift."), (true));
					}
					if (entity instanceof EntityLivingBase)
						((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH, (int) 30, (int) 1));
				} else {
					if (entity instanceof EntityPlayer)
						((EntityPlayer) entity).inventory
								.clearMatchingItems(new ItemStack(Items.NETHER_STAR, (int) (1)).getItem(), -1, (int) 1, null);
					if ((new ItemStack(((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() : null),
							(int) (1)).getItem() == new ItemStack(mcreator_copyMe.block, (int) (1)).getItem() && new ItemStack(
							((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() : null), (int) (1))
							.getMetadata() == new ItemStack(mcreator_copyMe.block, (int) (1)).getMetadata())) {
						if (entity instanceof EntityLivingBase)
							((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, (int) 60, (int) 2));
						if (entity instanceof EntityLivingBase)
							((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int) 60, (int) 2));
						if (entity instanceof EntityPlayer && !world.isRemote) {
							((EntityPlayer) entity).sendStatusMessage(new TextComponentString("Nether Gods: You anger us with your disrespect"),
									(true));
						}
						if (entity instanceof EntityPlayerMP) {
							MinecraftServer mcserv = FMLCommonHandler.instance().getMinecraftServerInstance();
							if (mcserv != null)
								mcserv.getCommandManager().executeCommand((EntityPlayerMP) entity, "weather rain");
						}
						world.createExplosion(null, (int) x, (int) y, (int) z, (float) 5, true);
					} else {
						if (entity instanceof EntityPlayer)
							((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(((entity instanceof EntityLivingBase)
									? ((EntityLivingBase) entity).getHeldItemMainhand().getItem()
									: null), (int) (1)));
					}
				}
			} else {
				if (entity instanceof EntityPlayer && !world.isRemote) {
					((EntityPlayer) entity).sendStatusMessage(new TextComponentString("Nether Gods: Rejected!!"), (true));
				}
				if (entity instanceof EntityLivingBase)
					((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, (int) 60, (int) 2));
				entity.attackEntityFrom(DamageSource.GENERIC, (float) 1.5);
			}
		}
	}

	public static Object instance;

	public void load(FMLInitializationEvent event) {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
	}

	public void registerRenderers() {
	}

	public int addFuel(ItemStack fuel) {
		return 0;
	}
}

 

Submitted by Klemen on Thu, 09/13/2018 - 09:07

There is no logs in neither the procedure nor the code. Are you sure you gave me the right procedure?

I never said it was just the logs I was giving you a example of a sub is what does not work no sub ID working the in hand command if only copying or showing the main of eg is I have a log in my hand it won’t clone the log 17#2 it will always give me the 0 index so 17#0

https://youtu.be/rVByn0wOyEE

In this video I show using a item with a sub is or indexed items what ever you like to call it you will see it gives the id#0 not the id#number it was meant to 

 

I have also added a image here I added a print command to when I was getting and you can see I am getting in return is not what I have the first two blocks are returning the last two blocks.

1

https://i.imgur.com/EubAm2Q.png

 

As you can see here all the first 3 blocks all have the same information so the game thinks it's another block, in order these are 17/1,17/2,/17/3 and 162/1 

2

https://i.imgur.com/js3dZ8E.png

But they all return 17/0 or 162/0 this happens for all blocks and items what are a item ID with a block index after it get hand is only getting the base ID not the id after it to tell the game or the player witch version of that block or item it is and since many mods group there items under one ID for each block type rather then each item having it's own ID it means many items can't be cloned as it will only return the base ID "ID/0"

Submitted by Klemen on Thu, 09/13/2018 - 11:36

Thank you for the info. I will check what could be causing this and try to fix this bug.

This does not seem to be on the change log, have you missed this bug out ? it's kinda one that needs fixing to use this option right.

OK thanks for clearing that up long as I not going mad lol I will try wait off until 1.8.2 then as the mod will and does work with the new version of forge so no need to recomplie