• Posts

    • First of all, don't reference FMLJavaModLoadingContext directly from that class, put it as a parameter in the PotionRegistryHandler#init method, second of all, you never even register your potions by calling EFFECTS#register, and lastly, your DeferredRegisters have their names mixed up, the first one is for effects and the second one is for potions.
    • I don't use SpongeForge and I don't find my problem there I use spigot
    • Im trying to make a server for me and my friends but it keeps coming up with this error when i try to join the server. I already tried logging out and in my minecraft account but it doesn't do anything.  
    • Plugins? Is your server using SpongeForge? See the FAQ entry in that case.
    • I ended up solving this with some help from the MinecraftByExample repo. public class Pet { private EntityType<?> entityType; public Pet() { this.entityType = null; } public String getEntityTypeString() { if (this.entityType == null) { return null; } return EntityType.getKey(this.entityType).toString(); } public EntityType<?> getEntityType() { return this.entityType; } public void setEntityType(String entityType) { this.entityType = EntityType.byKey(entityType).get(); } public void setEntityType(EntityType<?> entityType) { this.entityType = entityType; } } public class PetCapability { @CapabilityInject(Pet.class) public static Capability<Pet> CAPABILITY_PET = null; public static void register() { CapabilityManager.INSTANCE.register(Pet.class, new PetStorage(), () -> new Pet()); } public static class PetStorage implements IStorage<Pet> { @Override public void readNBT(Capability<Pet> capability, Pet instance, Direction side, INBT nbt) { if (nbt instanceof CompoundNBT && ((CompoundNBT) nbt).contains("type")) { String entityType = ((CompoundNBT) nbt).getString("type"); instance.setEntityType(entityType); } } @Override public INBT writeNBT(Capability<Pet> capability, Pet instance, Direction side) { CompoundNBT result = new CompoundNBT(); String entityTypeString = instance.getEntityTypeString(); if (entityTypeString != null) { result.putString("type", entityTypeString); } return result; } } } public class PetCapabilityProvider implements ICapabilitySerializable<INBT> { private Pet pet = new Pet(); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if (cap == PetCapability.CAPABILITY_PET) { return (LazyOptional<T>) LazyOptional.of(() -> pet); } return LazyOptional.empty(); } @Override public INBT serializeNBT() { return PetCapability.CAPABILITY_PET.writeNBT(pet, null); } @Override public void deserializeNBT(INBT nbt) { PetCapability.CAPABILITY_PET.readNBT(pet, null, nbt); } } Then register in the FMLCommonSetupEvent in your mod event subscriber and in your item class add the following function: @Override public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) { return new PetCapabilityProvider(); } Whenever you want to access the capability, just get the ItemStack and call GetCapability on it. If it's null, something went wrong, but if it's an instance of Pet, you can access it!
  • Topics

  • Who's Online (See full list)