• Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have been searching around in the code for a while and haven't found the variable that decides if the player is looking in f5 mode or not. Can somebody tell me if they know what it is because I need it for my mod.   Version 1.16.
    • The values saved in playerdata file. However, the values aren't imported when login. How do I fix?   Main: public static final ResourceLocation CAP_RESOURCE = new ResourceLocation(MODID, "capabilities"); public TestMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(TestMod::onFMLCommonSetup); } @SubscribeEvent public static void onFMLCommonSetup(FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IMyCapability.class, new MyCapabilityStorage(), () -> new MyCapability(2.0f)); } @SubscribeEvent public static void attachCapability(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof PlayerEntity)) return; event.addCapability(CAP_RESOURCE, new MyCapabilityProvider()); }   Provider: public class MyCapabilityProvider implements ICapabilitySerializable<INBT> { @CapabilityInject(IMyCapability.class) public static final Capability<IMyCapability> CAP = null; private LazyOptional<IMyCapability> instance = LazyOptional.of(CAP::getDefaultInstance); @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return CAP.orEmpty(cap, instance); } @Override public INBT serializeNBT() { return (INBT) CAP.getStorage().writeNBT(CAP, instance.orElseThrow(() -> new IllegalArgumentException("at serialize")), null); } @Override public void deserializeNBT(INBT nbt) { CAP.getStorage().readNBT(CAP, instance.orElseThrow(() -> new IllegalArgumentException("at deserialize")), null, nbt); } }   Storage: public class MyCapabilityStorage implements Capability.IStorage<IMyCapability> { @Override public INBT writeNBT(Capability<IMyCapability> capability, IMyCapability instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putFloat("cap1", instance.getCap1()); tag.putFloat("cap2", instance.getCap2()); tag.putFloat("cap3", instance.getCap3()); return tag; } @Override public void readNBT(Capability<IMyCapability> capability, IMyCapability instance, Direction side, INBT nbt) { CompoundNBT tag = (CompoundNBT) nbt; instance.setCap1(tag.getFloat("cap1")); instance.setCap2(tag.getFloat("cap2")); instance.setCap3(tag.getFloat("cap3")); } }  
    • Well, that simple yet genius idea has just worked, thanks so much 😄
    • Sorry i was already typing when you answered this. My "Absolutely not" was in response to this code snippet: public class RubyBlock extends Block { public RubyBlock() { super(Block.Properties.create(Material.IRON) .catchFire(true) // The rest of the methods in TNTBlock.java ); } } Extending vanilla classes is right, then you override the methods you need
  • Topics

  • Who's Online (See full list)