Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StaffProvider implements ICapabilitySerializable<CompoundNBT>
- {
- private final DefaultStaffCapability staff = new DefaultStaffCapability();
- private final LazyOptional<IStaff> staffLazyOptional = LazyOptional.of(() -> staff);
- public void invalidate() { staffLazyOptional.invalidate(); }
- @Nullable
- @Override
- public <T> LazyOptional<T> getCapability( Capability<T> cap, Direction side) {
- return staffLazyOptional.cast();
- }
- @Override
- public CompoundNBT serializeNBT() {
- if(StaffCapability.STAFF == null)
- return new CompoundNBT();
- else
- return (CompoundNBT) StaffCapability.STAFF.writeNBT(staff, null);
- }
- @Override
- public void deserializeNBT(CompoundNBT nbt) {
- if(StaffCapability.STAFF != null)
- StaffCapability.STAFF.readNBT(staff, null, nbt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement