Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReArmerProvider implements ICapabilitySerializable<INBT> {
- @CapabilityInject(IReArmer.class)
- public static final Capability<IReArmer> REARMER_CAPABILITY = null;
- private LazyOptional<IReArmer> instance = LazyOptional.of(REARMER_CAPABILITY::getDefaultInstance);
- @Nonnull
- @Override
- public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
- return cap == REARMER_CAPABILITY ? instance.cast() : LazyOptional.empty(); }
- @Override
- public INBT serializeNBT() {
- return REARMER_CAPABILITY.getStorage().writeNBT(REARMER_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null);
- }
- @Override
- public void deserializeNBT(INBT nbt) {
- REARMER_CAPABILITY.getStorage().readNBT(REARMER_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment