
nenikitov
Members-
Posts
28 -
Joined
-
Last visited
nenikitov's Achievements

Tree Puncher (2/8)
1
Reputation
-
So, after spending almost the whole day reading and rereading different tutorials, forum topics and source codes, after restarting 5 times i still didnt make it XD. I get a crash while attaching capabilities on PlayerEntity, more precisely on calling event.getObject() inside NeModEventHandler; Here are classes, their code and crash report: NeModEventHandler: INePlayerCapabilities: NePlayerCapabilities: NePlayerCapabilitiesProvider: NePlayerCapabilitiesStorage: And here is my crash report: Any ideas what is happening?
-
Yeah, I know and I'm getting whats happening. And sorry about copying your code.
-
Yeah, my fault. Passed the wrong thing. I should recreate all first and then see what is and what isnt working. Nevermind about
-
package com.nenikitov.nemod.playerCapabilities; import javax.annotation.Nullable; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; public class CapabilityRegestry { @CapabilityInject(INeModPlayerCapabilities.class) public static Capability<INeModPlayerCapabilities> COOLDOWN_ITEM = null; public static void registerCapabilities(){ CapabilityManager.INSTANCE.register(INeModPlayerCapabilities.class, new INeModPlayerCapabilities() ,INeModPlayerCapabilities::new); } public static class INeModPlayerCapabilities implements Capability.IStorage<INeModPlayerCapabilities>{ @Override public INBT writeNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side) { CompoundNBT nbt = new CompoundNBT(); nbt.putDouble("stamina", instance.GetStamina()); return nbt; } @Override public void readNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.SetStaminaValue(tag.getDouble("stamina")); } } } Yeah, but it shouldnt get these 2 methods from INeModPlayerCapabilities?
-
The method SetStaminaValue(double) is undefined for the type CapabilityRegestry.INeModPlayerCapabilities
-
Any idea why this is happening? In CapabilityRegistry @Override public INBT writeNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side) { CompoundNBT nbt = new CompoundNBT(); nbt.putDouble("stamina", instance.GetStamina()); return nbt; } I get "GetStamina()" unerlined red Although I have this method in my INeModPlayerCapabilities public double GetStamina(); And inide my NeModPlayerCapabilities @Override public double GetStamina() { return this.Stamina; } Actually same thing with @Override public void readNBT(Capability<INeModPlayerCapabilities> capability, INeModPlayerCapabilities instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.SetStaminaValue(tag.getDouble("stamina")); }
-
OK, thank you. I hope it helps me because all the tutorials and examples i saw, they wrote all differently + they were outdated. @SubscribeEvent public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(); } But the line event.addCapability(); isnt finished and there should be something written inside () , still dont know what because i didnt get to this point
-
Did you succeed on making a custom working capability?
-
After creating a PlayerCapabilities class and making it implement ICapabilitySerializable, importing everything and adding unemplemented methods i get this: package com.nenikitov.nemod; import net.minecraft.nbt.INBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; public class PlayerCapabilities implements ICapabilitySerializable<INBT> { @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { // TODO Auto-generated method stub return null; } @Override public INBT serializeNBT() { // TODO Auto-generated method stub return null; } @Override public void deserializeNBT(INBT nbt) { // TODO Auto-generated method stub } } 1. Its here after "public class PlayerCapabilities implements ICapabilitySerializable<INBT> {" that I should write all my new variables that I want to add as stats to the player, right? 2. When i'm regestering PlayerCapabilities (i'm doing it inside FMLCommonSetupEvent in my mod class), what should i put as storage and factory? CapabilityManager.INSTANCE.register(PlayerCapabilities.class, storage, factory); 3. For adding capabilities to the PLayerEntity, in my mod calss i wrote private static ResourceLocation PlayerCapabilitiesResourceLocation = new ResourceLocation(modid, "player_capabilities"); And then i wrote this method @SubscribeEvent public static void attachPlayerCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(PlayerCapabilitiesResourceLocation, cap); } } What should go in cap?
-
Ok, thank you. I will try to make it work, i guess it should be better. If something doesnt work, i will ask it.
-
1. What are forge provided capabilities for? I get what is IItemHandler, but the other 2, like what is fluid inventory and energy container? 2. What is EnumFacing? 3. Documentation shows the creation of custom capabilities with 3 separate classes, capability, storage and factory. Then they show what is written in storage and factory class. So they leave cabability class empty or what should be written there? 4. After i ve written a custom capability, where should i inject it? In which class? 5. I didnt get in which class i should register my capability? --------- 6. Maybe there is an example code of working capability which i can read to understand better what and where should be done?
-
Hello! I'm currently working on adding stamina system in minecraft and i face a problem where i need to add "stamina" variable to each client. Firstly, I would like to know did I get it right that capabilities is the correct way of doing it. Secondly, i have watched already numerous tutorials and have red documentation about capabilities, but I still can't get how to make it work, I don't understand how to make your own capability and attach it to the PlayerEntity. Thanks in advance.
-
[1.14] Custom armor with vanilla repair items
nenikitov replied to nenikitov's topic in Modder Support
Hmmm. Importing did help. Weird that importing wasn't in quick fixes. Well, anyways, thanks for making it work. -
[1.14] Custom armor with vanilla repair items
nenikitov replied to nenikitov's topic in Modder Support
On of my voids, all variables are declared before it so this works good. private ArmorMaterialList(String name, int[] durability, int[] damageReductionAmmounts, int enchantability, String equipSound, float toughness, Item repairItem) { this.name = name; this.durability = durability; this.damageReductionAmmounts = damageReductionAmmounts; this.enchantability = enchantability; this.equipSound = equipSound; this.toughness = toughness; this.repairItem = repairItem; } Here in the line reinforced_iron("reinforced_iron", new int[] {183, 249, 298, 216}, new int[] {3, 6, 7, 3}, 11, "item.armor.equip_iron", 0.0f, Items.IRON_INGOT), Items is underlined with red And there is no import fixes -
I've created my custom armor and i want it to have iron ingots as repair item. The problem is I simply don't know what should I write to get Item from vanilla game. For example for getting my custom Items I can use ItemList.ITEMNAME (I have ItemList class with all my items). But what shoul I write to get vanilla iron ingot?