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
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 :)
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;
}
}
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
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.
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
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"
Hey do we think this will be fixed in 1.8.2 kind of really need to to be able to go some cool things and I know a hand full of mods here are replying on this function and at the moment all are broken you forgot it in 1.8.1 or didn't have time but we really could do with this so we can fix mods, please add it so we can get all items and there ID's rather then just the base ID please :)
I am sorry but this most likely won't make it in 1.8.2. I think I have found the cause for this, but a lot of procedure system restructuring will have to be done and this includes the risk of new bugs. As a lot of new features were already added in 1.8.2 and these can have bugs too, we will have to postpone this issue so things remain under control. I hope this answered your question.
Well yes but it kinda of upsets me I been waiting to fix this bloody bug and so have others whom have made mods like mine and a few whom need it to check a item sub type, kinda feels like we can't trust a word you say as you been saying for about 2 versions now to fix this.
unpack the dam templates so we can fix these things ourselves or give us the option to take the risk of functions that could create bugs is used as this is getting a joke now.
I be willing to do that if you know what the fix is, I really don't mind locking the mod elements I had to in all older versions for the log rotations so I be willing to do it again, if you can provide a fix even tho it as to be done to each elements I be happy to do that until a future fix.
One example how to fix this would be this (I used part of your code for example):
new ItemStack((entity instanceof EntityLivingBase) ? ((EntityLivingBase)entity).getHeldItemMainhand().getItem() : null)
change this to
((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : null)
Explanation:
Basically, the original code calls getItem() on itemstack wich returns item, but no metadata and creates a new itemstack out of it, now with default metadata. New code bypasses this step and metadata is preserved.
This seems like a trivial fix for a person, but inside MCreator, we do this with reason that by converting everything to itemstack, we have a universal object (itemstack) for both items and blocks. As I said, this can be fixed in MCreator too, but will require a lot of changes and I don't want to rush with this due to new potential bugs that could be introduced by doing this.
I will give this change a try this coming week and many of us don't mine waiting for fix's we now one change can kill something else as long as we have some kind of work around, so I give this a test later thanks Just need to be at my desktop to be able to test it :)
Thanks for now and I hope to see it in the future but also happy for the temp fix.
OK I getting a error when making your change
From
EntityItem entityToSpawn = new EntityItem(world, x, y, z, new ItemStack(((entity instanceof EntityLivingBase)
? ((EntityLivingBase) entity).getHeldItemMainhand().getItem()
: null), (int) (1)));
To
EntityItem entityToSpawn = new EntityItem(world, x, y, z, new ItemStack(((entity instanceof EntityLivingBase)
? ((EntityLivingBase) entity).getHeldItemMainhand()
: null), (int) (1)));
But I get this error:
error: no suitable constructor found for ItemStack((entity in[...] null,int) EntityItem entityToSpawn = new EntityItem(world, x, y, z, new ItemStack(((entity instanceof EntityLivingBase) ^ constructor ItemStack.ItemStack(Block,int) is not applicable (argument mismatch; bad type in conditional expression ItemStack cannot be converted to Block) constructor ItemStack.ItemStack(Item,int) is not applicable (argument mismatch; bad type in conditional expression ItemStack cannot be converted to Item)
Is there something we missed here I read over this post a few times and I am sure I changed them right.
Also I reading this I don't think this will fix the problem at hand the problem is when you try copy a a item was is a sub ID are you sure this will fix that?
Logs are ID 17 and 162 so to get lets say Dark Oak the id is a sub id 1 (162:1) or Birch what is a sub id of 2 (17:2)
The problem we are having it's stripping the end sub id away and only returning 162 or 17, it's not returning the rest of it eg: 17:2
OK
EntityItem entityToSpawn = new EntityItem(world, x, y, z, ((entity instanceof EntityLivingBase)
? ((EntityLivingBase) entity).getHeldItemMainhand()
: null));
Does clone the right ID now but I rather give them a new items with no damage is that possible? I unable to create a new stack and unable to use .getItem() at the as it will give a error
error: incompatible types: bad type in conditional expression ? ((EntityLivingBase) entity).getHeldItemMainhand().getItem() ^ Item cannot be converted to ItemStack
Could you paste the lines that have the error too? One solution from the error itself would be to simply remove getItem() as this converts itemstack to item, but you actually need itemstack.
In order to remove the damage from the item, you would need to save itemstack to a variable and call setItemDamage(0) on the itemstack before using it.
Most likely this is already itemstack. Store this variable to an itemstack, could be something like this:
ItemStack stack = ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : null);
if(stack != null) {
stack.setItemDamage(0);
EntityItem entityToSpawn = new EntityItem(world, x, y, z, stack);
}
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?