The Meaning of Life, the Universe, and Everything.
Join Date:
4/23/2017
Posts:
60
Member Details
I recently decided to make a TileEntity for my mod. With it, you right click with a knife, and it will take the knife away and put it in the knife rack. But, the only tutorial I could find was for 1.10, and I got these errors... Please help!
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound){
super.writeToNBT(compound);
compound.setInteger("knives", this.knives);
return compound;
}
//The Error, it was on NBTTagCompound at the very beginning - The return type is incompatible with TileEntity.writeToNBT(NBTTagCompound)
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote){
TileEntity tileEntity = worldIn.getTileEntity(pos);
if(tileEntity instanceof TileEntityRack){
TileEntityRack knife_rack = (TileEntityRack) tileEntity;
if(heldItem != null){
if(heldItem.getItem() == FoodsPlusItems.knife){
if(knife_rack.addKnife()){
heldItem.stackSize--;
return true;
}
}
}
knife_rack.removeKnife();
}
}
return true;
}
//The Error, it was on EnumHand on the second line - EnumHand cannot be resolved to a type
The Meaning of Life, the Universe, and Everything.
Join Date:
4/23/2017
Posts:
60
Member Details
Thank you, I was able to fix the first error. But, I couldn't find anything on the second error. It seems like EnumHand doesn't exist in 1.8, so I searched for anything having to do with onBlockActivated through all of the TileEntity classes. Though, I haven't finished the tutorial, which might be a problem somehow. I did search for isRemote on a few classes (including flower pot bc that is the most similar thing to what I am adding), but didn't find anything there. Any suggestions?
The Meaning of Life, the Universe, and Everything.
Join Date:
4/23/2017
Posts:
60
Member Details
The onBlockActivated is in the Block class, so that's good. Also, I misspoke and I did finish the tutorial, so I didn't miss anything in it. And, if I put the onBlockActivated method from the Block class, errors the 3 heldItem with "Cannot be resolved to a variable"
I recently decided to make a TileEntity for my mod. With it, you right click with a knife, and it will take the knife away and put it in the knife rack. But, the only tutorial I could find was for 1.10, and I got these errors... Please help!
Thank you, I was able to fix the first error. But, I couldn't find anything on the second error. It seems like EnumHand doesn't exist in 1.8, so I searched for anything having to do with onBlockActivated through all of the TileEntity classes. Though, I haven't finished the tutorial, which might be a problem somehow. I did search for isRemote on a few classes (including flower pot bc that is the most similar thing to what I am adding), but didn't find anything there. Any suggestions?
The onBlockActivated is in the Block class, so that's good. Also, I misspoke and I did finish the tutorial, so I didn't miss anything in it. And, if I put the onBlockActivated method from the Block class, errors the 3 heldItem with "Cannot be resolved to a variable"