use of net.minecraftforge.event.AttachCapabilitiesEvent in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ControlEventsCommon method onAttachCapabilityEventItem.
@SubscribeEvent
public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) {
if (event instanceof AttachCapabilitiesEvent.Item) {
AttachCapabilitiesEvent.Item itemEvent = (AttachCapabilitiesEvent.Item) event;
ItemStack stack = itemEvent.getItemStack();
if (itemEvent.getItem() instanceof ItemRelayWire) {
// System.out.println("Obama?");
event.addCapability(new ResourceLocation(ValkyrienWarfareControlMod.MODID, "LastRelay"), new ICapabilitySerializable<NBTTagIntArray>() {
ICapabilityLastRelay inst = ValkyrienWarfareControlMod.lastRelayCapability.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ValkyrienWarfareControlMod.lastRelayCapability;
}
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ValkyrienWarfareControlMod.lastRelayCapability ? ValkyrienWarfareControlMod.lastRelayCapability.<T>cast(inst) : null;
}
@Override
public NBTTagIntArray serializeNBT() {
return (NBTTagIntArray) ValkyrienWarfareControlMod.lastRelayCapability.getStorage().writeNBT(ValkyrienWarfareControlMod.lastRelayCapability, inst, null);
}
@Override
public void deserializeNBT(NBTTagIntArray nbt) {
ValkyrienWarfareControlMod.lastRelayCapability.getStorage().readNBT(ValkyrienWarfareControlMod.lastRelayCapability, inst, null, nbt);
}
});
}
}
}
Aggregations