A problem with reading a variable

Started by Hazzah_ on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A problem with reading a variable

I'm trying to make a spear item, and having some problems with dropping an item after it hits something.

So the basic procedure looks like this: 

The "spear_damage" variable is an item that I set to the thrown spear in this procedure:

 So, what I'm expecting it to do is:

 When thrown: Deal 1 damage to the item, save the item as a variable, remove the item from inventory

and When it hits a block: Spawn the saved item from the variable.

Here, I have 2 issues:

But the major one is, when it hits an entity , any type of variable I try to read is set to nothing. The itemstack variable is set to "air" or an empty itemstack, and number variables are set to 0. (I tried saving only the durability value, not the whole item.) 

I made sure the variables are not mentioned anywhere besides these two procedures.