
nenikitov
Members-
Posts
28 -
Joined
-
Last visited
Everything posted by nenikitov
-
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?
-
How I did my key bindings: I created a class "KeyBindingList": (342 is a integer assigned to left alt key. Idk why, i couldnt get Keyboard.KEY_LALT to work, so i used a trich with writing the ingeer directly. IF you will need to do like I did, when all the code is setup and you are in game, you can press any key and it should write the integer in the console) public class KeyBindingList { public static KeyBinding[] ModKeyBindings; public static void register() { ModKeyBindings = new KeyBinding[1]; //Create array //Assign all key binds to this array ModKeyBindings[0] = new KeyBinding("KEY.MODID.ACTION", 342, "KEY.MODID.category"); //Actually register all keys for (int i = 0; i < ModKeyBindings.length; ++i) { ClientRegistry.registerKeyBinding(ModKeyBindings[i]); } } Dont foger to replace MODID and ACTION in "key.MODID.ACTION" and "key.MODID.category" with your modid and action that you want to make. Then I created a class "KeyBindingList": public class ModInputHandler { @SubscribeEvent public void onKeyInput(KeyInputEvent event) { System.out.println(event.getKey()); if (KeyBindingList.ModKeyBindings[0].isPressed()) //If first key is pressed { System.out.println("KEY IS PRESSED"); } } } Then in my mod class in the setup void I added: MinecraftForge.EVENT_BUS.register(new ModInputHandler()); Dont forget to add these lines into your en_us: "key.MODID.ACTION": "ACTION NAME", "key.MODID.category": "CATEGORY NAME", Of course with changing MODID, ACTION, ACTION NAME and CATEGORY NAME. After all of this you should have a category in Control Settings with your CATEGORY NAME and you will be able to rebind it to whatever you like. In game, it should print in console KEY IS PRESSED whenever your key is pressed. Hope this helps.
-
If someone is interested, there is a possibility to launch the player. Use "playerEntity.setMotion(x, y, z)"
-
Hello! I'm currently trying to set up a dodge move and i have difficulties with moving the player. I have 3 ideas: -Teleport the player by adding to his cooordinates his movement direction multiplied by dodge length. When i use ".teleportKeepLoaded", it seems like the player teleports only on client side: when i start moving wirth WASD, my location resets to location before teleporting. -Give a speed boost to the player for a fraction of the second and then set his walking speed to normal. But when i change the walking speed, nomatter what i put, the speed isn't affected, just player's FOV and that's all. -Launch player in the moving direction and a bit up, my prefered method, but i dont know how to implement this. Any ideas or suggestions how to fix the problems?
-
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
Yep, "BUILD SUCCESSFUL" Thanks -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
It seems like it's working: it's now downloading all resources needed (currently, sounds) and it's on "EXECUTING 12%" Gonna write when it finishes Thanks a lot -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
OK, i will try -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
java -version: echo %JAVA_HOME%: -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
Ok, i will do it. Sorry, it's gonna be tomorrow, i can't right now. Thanks for the help for now. -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
Yes, i did follow every step and i did restart it. I also restarted my PC after adding paths to java in advanced settings. -
Can not install Forge MDK 1.14.4 - 28.1.0
nenikitov replied to nenikitov's topic in Support & Bug Reports
I was following this tutorial. I assume it should be the same method for 1.14.4. Except i've red that you shouldnt run ""grandlew setupDecompWorkspace" after minecraft 1.13.0 with needed version of forge.