Search the Community
Showing results for tags 'resolved'.
-
I am Attempting to register a custom capability to NBT running (mostly) off of a tutorial and failing miserably. I have spoken with someone familiar with Java, and both they and my IDE concur that there is no outward problem with my code, so I believe there is a problem with my implementation (likely caused by a mixture of ignorance and new versions. Github linked, if anyone is able to help, that would be greatly appreciated https://github.com/Zebralear/SoulCraft
- 2 replies
-
- 1.19.2
- capabilities
-
(and 1 more)
Tagged with:
-
FIX: So there was three problems, one was the mod ID for baubles is actually Baubles, and 2 is I needed to removed the .class. The third is I needed an @Optional.Method above the method. Hope this helps anyone who finds it! So I'm trying to figure out how to use the @Optional annotation and it is not going well. The class code is below. On the line that says @Optional.Interface(iface="IBauble",modid="baubles") I have also tried @Optional.Interface(iface="baubles.api.IBauble.class",modid="baubles") and got the same crash.(The crash report is a classNotFound blah blah error, file attached.) import java.util.List; import com.theundertaker11.kitchensink.KitchenSink; import com.theundertaker11.kitchensink.event.WorldTick; import baubles.api.BaubleType; import baubles.api.IBauble; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Optional.Interface(iface="IBauble",modid="baubles") public class blessedRock extends ItemBase implements IBauble{ public blessedRock(String name){ super(name, true); this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("What could a rock ever... Oh!"); } @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; String username = player.getGameProfile().getName(); if(!WorldTick.PlayersWithFlight.contains(username)) WorldTick.PlayersWithFlight.add(username); player.capabilities.allowFlying = true; } } @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.TRINKET; } } crash-2017-02-03_17.09.11-client.txt