Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

marinz

Members
  • Joined

  • Last visited

Everything posted by marinz

  1. even a 4yo child would get it by now... I told u before that I don't understand it so why continue to say to read that. Nevermind I find the way but pay attention to what you write and what others write.
  2. How do I register it
  3. I tryed but I don't understand it
  4. I am trying to find the way but I just can't find it
  5. Still don't understand what you want to say
  6. package com.tzs.asm.capability; import java.util.concurrent.Callable; 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.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; public class PlayerCapability { @CapabilityInject(IPlayerCapability.class) public static Capability<IPlayerCapability> PLAYER_CAPABILITY = null; public static class Storage implements IStorage<IPlayerCapability> { @Override public INBT writeNBT(Capability<IPlayerCapability> capability, IPlayerCapability instance, Direction side) { CompoundNBT props = new CompoundNBT(); props.putBoolean("hasGotSword", instance.hasGotSword()); return (INBT)props; } @Override public void readNBT(Capability<IPlayerCapability> capability, IPlayerCapability instance, Direction side, INBT nbt) { CompoundNBT props = (CompoundNBT)nbt; instance.getSword(props.getBoolean("hasGotSword")); } } public static class PlayerCapabilityFactory implements Callable<IPlayerCapability> { @Override public IPlayerCapability call() throws Exception { return null; } } public static class PlayerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> { private PlayerCapabilityBase playerCapabilityBase = new PlayerCapabilityBase(); private LazyOptional<PlayerCapabilityBase> playerCapabilityOptional = LazyOptional.of(() -> playerCapabilityBase); @SuppressWarnings("unchecked") @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == PLAYER_CAPABILITY ? (LazyOptional<T>) playerCapabilityOptional : LazyOptional.empty(); } @Override public CompoundNBT serializeNBT() { return this.serializeNBT(); } @Override public void deserializeNBT(CompoundNBT nbt) { this.deserializeNBT(nbt); } } } package com.tzs.asm; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.tzs.asm.capability.IPlayerCapability; import com.tzs.asm.capability.PlayerCapability; import com.tzs.asm.config.asmConfig; import com.tzs.asm.init.ItemInit; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig.Type; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("asm") public class asmMain { public static String MODID = "asm"; public static final Logger LOGGER = LogManager.getLogger(); public asmMain() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); ItemInit.ITEMS.register(bus); ModLoadingContext.get().registerConfig(Type.COMMON, asmConfig.SPEC, "asmConfig.toml"); MinecraftForge.EVENT_BUS.register(this); } public static void FMLCommonSetupEvent() { CapabilityManager.INSTANCE.register(IPlayerCapability.class, new PlayerCapability.Storage(), new PlayerCapability.PlayerCapabilityFactory()); } }
  7. It crashes when I try to join world now.
  8. package com.tzs.asm.capability; import java.util.concurrent.Callable; 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.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; public class PlayerCapability { @CapabilityInject(IPlayerCapability.class) public static Capability<IPlayerCapability> PLAYER_CAPABILITY; public static class Storage implements IStorage<IPlayerCapability> { @Override public INBT writeNBT(Capability<IPlayerCapability> capability, IPlayerCapability instance, Direction side) { CompoundNBT props = new CompoundNBT(); props.putBoolean("hasGotSword", instance.hasGotSword()); return (INBT)props; } @Override public void readNBT(Capability<IPlayerCapability> capability, IPlayerCapability instance, Direction side, INBT nbt) { CompoundNBT props = (CompoundNBT)nbt; instance.getSword(props.getBoolean("hasGotSword")); } } public static class PlayerCapabilityFactory implements Callable<IPlayerCapability> { @Override public IPlayerCapability call() throws Exception { return null; } } public static class PlayerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> { private PlayerCapabilityBase playerCapabilityBase = new PlayerCapabilityBase(); private LazyOptional<PlayerCapabilityBase> playerCapabilityOptional = LazyOptional.of(() -> playerCapabilityBase); @SuppressWarnings("unchecked") @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == PLAYER_CAPABILITY ? (LazyOptional<T>) playerCapabilityOptional : LazyOptional.empty(); } @Override public CompoundNBT serializeNBT() { return this.serializeNBT(); } @Override public void deserializeNBT(CompoundNBT nbt) { this.deserializeNBT(nbt); } } }
  9. public static class PlayerCapabilityFactory implements Callable<IPlayerCapability> { @Override public IPlayerCapability call() throws Exception { return null; } }
  10. Still crashes but now can't join minecraft. package com.tzs.asm; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.tzs.asm.capability.IPlayerCapability; import com.tzs.asm.capability.PlayerCapability; import com.tzs.asm.config.asmConfig; import com.tzs.asm.init.ItemInit; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig.Type; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("asm") public class asmMain { public static final Logger LOGGER = LogManager.getLogger(); public asmMain() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); ItemInit.ITEMS.register(bus); ModLoadingContext.get().registerConfig(Type.COMMON, asmConfig.SPEC, "asmConfig.toml"); MinecraftForge.EVENT_BUS.register(this); CapabilityManager.INSTANCE.register(IPlayerCapability.class, new PlayerCapability.Storage(), new PlayerCapability.PlayerCapabilityFactory()); } }
  11. Here it is. The setup method is never used @Mod("asm") public class asmMain { public static String MOD_ID = "asm"; public static final Logger LOGGER = LogManager.getLogger(); public asmMain() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); ItemInit.ITEMS.register(bus); ModLoadingContext.get().registerConfig(Type.COMMON, asmConfig.SPEC, "asmConfig.toml"); MinecraftForge.EVENT_BUS.register(this); } private void setup(FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IPlayerCapability.class, new PlayerCapability.Storage(), new PlayerCapability.PlayerCapabilityFactory()); } }
  12. Here is the code.
  13. minecraft crashes after trying to join the world here is the log.
  14. I did this but I still don't know how to attach capability here are some screenshots of what I've done. I've looked on forge doc and forge community wiki and still don't understand how that would be done.
  15. and how should I do that. I am sorry I don't really understand how to put that together
  16. That still means it will give it to any player that doesn't have that item
  17. I am not sure is that this. I want it to give a sword to player that joined for the first time on server/singleplayer world.
  18. wouldn't this just give player that item if he doesn't have it?
  19. Thank you for that I will definitly check that out, but can you tell me how to fix this for now.
  20. Not really I read all of that but how do I use that, where to put it how to put it I don't understand that. By the way is there any good website or something where I can learn more because I didn't find that much of explaining in yt videos and some website.
  21. I don't know what this part means and thats almost everything
  22. I removed almost everything I will just do the first time join to get the sword Screenscot shows code for giving it if you don't have it in inventory but I would like it appear when player joins for the first time
  23. Can anyone help?

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.