Search in sources :

Example 1 with ItemRelayWire

use of ValkyrienWarfareControl.Item.ItemRelayWire 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);
                }
            });
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray) AttachCapabilitiesEvent(net.minecraftforge.event.AttachCapabilitiesEvent) ItemRelayWire(ValkyrienWarfareControl.Item.ItemRelayWire) ResourceLocation(net.minecraft.util.ResourceLocation) ICapabilityLastRelay(ValkyrienWarfareControl.Capability.ICapabilityLastRelay) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemRelayWire

use of ValkyrienWarfareControl.Item.ItemRelayWire in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareControlMod method registerItems.

private void registerItems(FMLStateEvent event) {
    systemLinker = new ItemSystemLinker().setUnlocalizedName("systemlinker").setRegistryName(MODID, "systemlinker").setCreativeTab(CreativeTabs.TRANSPORTATION).setMaxStackSize(1);
    airshipStealer = new ItemShipStealer().setUnlocalizedName("airshipStealer").setRegistryName(MODID, "airshipStealer").setCreativeTab(CreativeTabs.TOOLS).setMaxStackSize(1);
    relayWire = new ItemRelayWire().setUnlocalizedName("relaywire").setRegistryName(MODID, "relaywire").setCreativeTab(CreativeTabs.TRANSPORTATION).setMaxStackSize(1);
    GameRegistry.register(systemLinker);
    GameRegistry.register(airshipStealer);
    GameRegistry.register(relayWire);
}
Also used : ItemSystemLinker(ValkyrienWarfareControl.Item.ItemSystemLinker) ItemRelayWire(ValkyrienWarfareControl.Item.ItemRelayWire) ItemShipStealer(ValkyrienWarfareControl.Item.ItemShipStealer)

Aggregations

ItemRelayWire (ValkyrienWarfareControl.Item.ItemRelayWire)2 ICapabilityLastRelay (ValkyrienWarfareControl.Capability.ICapabilityLastRelay)1 ItemShipStealer (ValkyrienWarfareControl.Item.ItemShipStealer)1 ItemSystemLinker (ValkyrienWarfareControl.Item.ItemSystemLinker)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)1 EnumFacing (net.minecraft.util.EnumFacing)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AttachCapabilitiesEvent (net.minecraftforge.event.AttachCapabilitiesEvent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1