Search in sources :

Example 16 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.

the class PlatingReturnHandler method onItemCrafted.

@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent evt) {
    if (evt.player.worldObj.isRemote || !(evt.crafting.getItem() instanceof ItemPack)) {
        return;
    }
    PackBase outputPack = ((ItemPack) evt.crafting.getItem()).getPack(evt.crafting);
    if (outputPack.isArmored) {
        return;
    }
    for (int i = 0; i < evt.craftMatrix.getSizeInventory(); i++) {
        ItemStack input = evt.craftMatrix.getStackInSlot(i);
        if (input == null || !(input.getItem() instanceof ItemPack)) {
            continue;
        }
        PackBase inputPack = ((ItemPack) input.getItem()).getPack(input);
        if (inputPack != null && inputPack.isArmored && inputPack.platingMeta != null) {
            EntityItem item = evt.player.entityDropItem(new ItemStack(ModItems.armorPlatings, 1, inputPack.platingMeta), 0.0F);
            item.delayBeforeCanPickup = 0;
            break;
        }
    }
}
Also used : PackBase(tonius.simplyjetpacks.item.meta.PackBase) ItemPack(tonius.simplyjetpacks.item.ItemPack) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 17 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.

the class EntityInteractHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent evt) {
    if (evt.entityPlayer.isSneaking() && (evt.target instanceof EntityZombie || evt.target instanceof EntitySkeleton)) {
        EntityLiving target = (EntityLiving) evt.target;
        ItemStack heldStack = evt.entityPlayer.getHeldItem();
        if (heldStack != null && heldStack.getItem() instanceof ItemJetpack) {
            if (!target.worldObj.isRemote) {
                target.dropEquipment(true, 3);
            }
            target.setCurrentItemOrArmor(3, heldStack.copy());
            target.equipmentDropChances[3] = 2.0F;
            target.persistenceRequired = true;
            evt.entityPlayer.getHeldItem().stackSize--;
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 18 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SimplyJetpacks by Tonius.

the class LivingTickHandler method mobUseJetpack.

@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
            Jetpack jetpack = jetpackItem.getPack(armor);
            if (jetpack != null) {
                if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
                    jetpack.setMobMode(armor);
                    jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
                }
            }
            if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
                evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
            }
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) JetpackPotato(tonius.simplyjetpacks.item.meta.JetpackPotato) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ItemStack(net.minecraft.item.ItemStack) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 19 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project BluePower by Qmunity.

the class IconSupplier method onTextureStitch.

@SubscribeEvent
public void onTextureStitch(TextureStitchEvent.Pre event) {
    TextureMap reg = event.map;
    if (reg.getTextureType() == 0) {
        pneumaticTubeSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side");
        pneumaticTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass");
        pneumaticTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass2");
        pneumaticTubeOpaqueSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side_opaque");
        pneumaticTubeOpaqueNode = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_end_opaque");
        restrictionTubeSide = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side");
        restrictionTubeNodeOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_end_opaque");
        restrictionTubeSideOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side_opaque");
        magTubeSide = reg.registerIcon(Refs.MODID + ":tubes/mag_side");
        magCoilSide = reg.registerIcon(Refs.MODID + ":tubes/mag_casing");
        magCoilFront = reg.registerIcon(Refs.MODID + ":tubes/mag_casing_end");
        magTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced");
        magTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced2");
        acceleratorFront = reg.registerIcon(Refs.MODID + ":machines/accelerator_front");
        acceleratorFrontPowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_front_powered");
        acceleratorSide = reg.registerIcon(Refs.MODID + ":machines/accelerator_side");
        acceleratorSidePowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_side_powered");
        acceleratorInside = reg.registerIcon(Refs.MODID + ":machines/accelerator_inside");
        pneumaticTubeColoring = reg.registerIcon(Refs.MODID + ":tubes/coloring");
        cagedLampFootSide = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_side");
        cagedLampFootTop = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_top");
        cagedLampCageSide = reg.registerIcon(Refs.MODID + ":lamps/cage");
        cagedLampCageTop = reg.registerIcon(Refs.MODID + ":lamps/cage_top");
        cagedLampLampActive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on");
        cagedLampLampInactive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off");
        cagedLampLampActiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on_top");
        cagedLampLampInactiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off_top");
        fixtureFootSide = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_side");
        fixtureFootTop = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_top");
        fixtureLampSideOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on");
        fixtureLampTopOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on_top");
        fixtureLampSideOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off");
        fixtureLampTopOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off_top");
        lampOn = reg.registerIcon(Refs.MODID + ":lamps/lamp_off");
        lampOff = reg.registerIcon(Refs.MODID + ":lamps/lamp_on");
        bluestoneTorchOff = reg.registerIcon(Refs.MODID + ":bluestone_torch_off");
        bluestoneTorchOn = reg.registerIcon(Refs.MODID + ":bluestone_torch_on");
        wire = reg.registerIcon(Refs.MODID + ":wire/wire");
        wireInsulation1 = reg.registerIcon(Refs.MODID + ":wire/insulation1");
        wireInsulation2 = reg.registerIcon(Refs.MODID + ":wire/insulation2");
        wireBundledConnection = reg.registerIcon(Refs.MODID + ":wire/bundled_connection");
        wireBundledCross = reg.registerIcon(Refs.MODID + ":wire/bundled_cross");
        wireBundledStraight1 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_1");
        wireBundledStraight2 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_2");
        wireBundledSide1 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_1");
        wireBundledSide2 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_2");
        gateButton = reg.registerIcon(Refs.MODID + ":gates/components/button");
        siliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_off");
        siliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_on");
        taintedSiliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_off");
        taintedSiliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_on");
        quartzResonator = reg.registerIcon(Refs.MODID + ":gates/components/resonator");
        gateSolarPanel = reg.registerIcon(Refs.MODID + ":gates/components/solarpanel");
        for (PartInfo i : PartManager.getRegisteredParts()) i.getExample().registerIcons(reg);
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) PartInfo(com.bluepowermod.part.PartInfo) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 20 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project LogisticsPipes by RS485.

the class LogisticsEventListener method clientLoggedIn.

@SubscribeEvent
public void clientLoggedIn(ClientConnectedToServerEvent event) {
    SimpleServiceLocator.clientBufferHandler.clear();
    if (Configs.CHECK_FOR_UPDATES) {
        LogisticsPipes.singleThreadExecutor.execute(() -> {
            // try to get player entity ten times, once a second
            int times = 0;
            EntityClientPlayerMP playerEntity;
            do {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    return;
                }
                playerEntity = FMLClientHandler.instance().getClientPlayerEntity();
                ++times;
            } while (playerEntity == null && times <= 10);
            if (times > 10) {
                return;
            }
            assert playerEntity != null;
            VersionChecker checker = LogisticsPipes.versionChecker;
            // send player message
            String versionMessage = checker.getVersionCheckerStatus();
            if (checker.isVersionCheckDone() && checker.getVersionInfo().isNewVersionAvailable() && !checker.getVersionInfo().isImcMessageSent()) {
                playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
                playerEntity.addChatComponentMessage(new ChatComponentText("Use \"/logisticspipes changelog\" to see a changelog."));
            } else if (!checker.isVersionCheckDone()) {
                playerEntity.addChatComponentMessage(new ChatComponentText(versionMessage));
            }
        });
    }
}
Also used : VersionChecker(logisticspipes.ticks.VersionChecker) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) ChatComponentText(net.minecraft.util.ChatComponentText) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)109 EntityPlayer (net.minecraft.entity.player.EntityPlayer)45 ItemStack (net.minecraft.item.ItemStack)45 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 World (net.minecraft.world.World)11 Minecraft (net.minecraft.client.Minecraft)10 ChunkPosition (net.minecraft.world.ChunkPosition)9 EntityItem (net.minecraft.entity.item.EntityItem)8 ChatComponentText (net.minecraft.util.ChatComponentText)8 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 AffinityData (am2.playerextensions.AffinityData)5 SideOnly (cpw.mods.fml.relauncher.SideOnly)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5 ExtendedProperties (am2.playerextensions.ExtendedProperties)4