Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Twingemios

Members
  • Posts

    5
  • Joined

  • Last visited

Twingemios's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. How can I do that? It requires that a LazyOptional must be returned in getCapability public class ChaosActsProvider implements ICapabilitySerializable<CompoundTag> { @CapabilityInject(IChaosActs.class) public static final Capability<IChaosActs> CAPABILITY = null; public static final ChaosActs instance = new ChaosActs(); @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return cap == CAPABILITY ? instance : LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { CompoundTag cnbt = new CompoundTag(); cnbt.putInt("timer",instance.getTimer()); return cnbt; } @Override public void deserializeNBT(CompoundTag nbt) { instance.setTimer(nbt.getInt("timer")); } }
  2. Then what do I do with this? It needs the instance @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == CAPABILITY ? instance.cast() : LazyOptional.empty(); }
  3. I am aware that I need to register the capabilities, I just haven't provided that code as far as I am pretty sure nothing has changed in that department. What do I do in place of the Factory and Storage for the capability?
  4. I'm trying to make some capabilities in 1.17 after moving from 1.16 and I can't figure out how I am supposed to do them now. This is how I did them in 1.16. public class Cooldowns implements ICooldowns { private int summonCooldown = 0; @Override public void setSummonCooldown(int var) { this.summonCooldown = var; } @Override public int getSummonCooldown() { return this.summonCooldown; } } public class CooldownCapability implements ICapabilitySerializable<CompoundNBT> { @CapabilityInject(ICooldowns.class) public static final Capability<ICooldowns> CAPABILITY = null; private LazyOptional<ICooldowns> instance = LazyOptional.of(CAPABILITY::getDefaultInstance); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == CAPABILITY ? instance.cast() : LazyOptional.empty(); } @Override public CompoundNBT serializeNBT() { return (CompoundNBT) CAPABILITY.getStorage().writeNBT(CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null); } @Override public void deserializeNBT(CompoundNBT nbt) { CAPABILITY.getStorage().readNBT(CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt); } } public class CooldownStorage implements IStorage<ICooldowns> { @Override public CompoundNBT writeNBT(Capability<ICooldowns> capability, ICooldowns instance, Direction side) { CompoundNBT cnbt = new CompoundNBT(); cnbt.putInt("summoncooldown",instance.getSummonCooldown()); return cnbt; } @Override public void readNBT(Capability<ICooldowns> capability, ICooldowns instance, Direction side, INBT nbt) { CompoundNBT inbt = (CompoundNBT) nbt; instance.setSummonCooldown(inbt.getInt("summoncooldown")); } } From I understand IStorage and getDefaultInstance are depreciated. What do I need to change in order to run this code on 1.17? I've tired to do a lot of research on this but it seems forge's read the docs for 1.17 is outdated as it still tells me to use IStorage.
  5. (Im very new to minecraft modding but not Java) How could I go about changing the player's model to another model like a Zombie? I've looked at how it is done in previous versions but with the changes to how rendering works in 1.15.2 it wont work (At least I don't think). UPDATE: I have figured it out and I will update this post with the code I used so that others can use it once I've fully finished it
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.