Search in sources :

Example 1 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 2 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Engine by VoltzEngine-Project.

the class ClientProxy method clientUpdate.

@SubscribeEvent
public void clientUpdate(TickEvent.WorldTickEvent event) {
    if (///TODO reduce check to every 10 ticks
    Engine.enableExtendedMetaPacketSync) {
        try {
            if (event.side == Side.CLIENT) {
                Minecraft mc = Minecraft.getMinecraft();
                if (mc != null) {
                    EntityPlayer player = mc.thePlayer;
                    World world = mc.theWorld;
                    if (player != null && world != null) {
                        if (ExtendedBlockDataManager.CLIENT.dimID != world.provider.dimensionId) {
                            ExtendedBlockDataManager.CLIENT.clear();
                            ExtendedBlockDataManager.CLIENT.dimID = world.provider.dimensionId;
                        }
                        int renderDistance = mc.gameSettings.renderDistanceChunks + 2;
                        int centerX = ((int) Math.floor(player.posX)) >> 4;
                        int centerZ = ((int) Math.floor(player.posZ)) >> 4;
                        //Clear out chunks outside of render distance
                        List<ChunkData> chunksToRemove = new ArrayList();
                        for (ChunkData data : ExtendedBlockDataManager.CLIENT.chunks.values()) {
                            if (Math.abs(data.position.chunkXPos - centerX) > renderDistance || Math.abs(data.position.chunkZPos - centerZ) > renderDistance) {
                                chunksToRemove.add(data);
                            }
                        }
                        for (ChunkData data : chunksToRemove) {
                            ExtendedBlockDataManager.CLIENT.chunks.remove(data.position);
                        }
                        renderDistance = mc.gameSettings.renderDistanceChunks;
                        for (int x = centerX - renderDistance; x < centerX + renderDistance; x++) {
                            for (int z = centerZ - renderDistance; z < centerZ + renderDistance; z++) {
                                ChunkData chunkData = ExtendedBlockDataManager.CLIENT.getChunk(x, z);
                                if (chunkData == null) {
                                    Engine.instance.packetHandler.sendToServer(new PacketRequestData(world.provider.dimensionId, x, z, 0));
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            Engine.logger().error("Unexpected error while updating client chunk data state", e);
        }
    }
}
Also used : ChunkData(com.builtbroken.mc.lib.world.map.data.ChunkData) PacketRequestData(com.builtbroken.mc.core.network.packet.callback.chunk.PacketRequestData) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Engine by VoltzEngine-Project.

the class ChunkMap method onChunkLoaded.

@SubscribeEvent
public void onChunkLoaded(ChunkEvent.Load event) {
    Chunk chunk = event.getChunk();
    ChunkCoordIntPair coords = chunk.getChunkCoordIntPair();
    if (chunks.containsKey(coords)) {
    //TODO load data into existing object
    } else {
    //TODO load object
    }
}
Also used : ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Chunk(net.minecraft.world.chunk.Chunk) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Minechem by iopleke.

the class AugmentLight method onBlockHarvest.

@SubscribeEvent
public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) {
    if (event.harvester != null) {
        ItemStack stack = event.harvester.getHeldItem();
        if (stack != null && stack.getItem() instanceof IAugmentedItem) {
            IAugmentedItem augmentedItem = (IAugmentedItem) stack.getItem();
            int level = augmentedItem.getAugmentLevel(stack, this);
            if (level > -1 && event.world.getBlockLightValue(event.x, event.y, event.z) < 8) {
                consumeAugment(stack, level);
                event.world.setBlock(event.x, event.y, event.z, BlockRegistry.blockLight, level, 3);
            }
        }
    }
}
Also used : IAugmentedItem(minechem.item.augment.IAugmentedItem) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class EventManager method onClientKeyPress.

/**
     * <h2>Keybind management</h2>
     * called when a client presses a key. this coveres pretty much everything.
     * Most cases just send a packet to manage things
     * @see PacketKeyPress
     *
     * Credit to Ferdinand for help with this function.
     *
     * @param event the event of a key being pressed on client.
     */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientKeyPress(InputEvent.KeyInputEvent event) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player.ridingEntity instanceof GenericRailTransport || player.ridingEntity instanceof EntitySeat) {
        //for lamp
        if (ClientProxy.KeyLamp.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(0, player.ridingEntity.getEntityId()));
            ((GenericRailTransport) player.ridingEntity).setBoolean(GenericRailTransport.boolValues.LAMP, !((GenericRailTransport) player.ridingEntity).getBoolean(GenericRailTransport.boolValues.LAMP));
        }
        //for inventory
        if (ClientProxy.KeyInventory.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(1, player.ridingEntity.getEntityId()));
        }
        if (player.ridingEntity instanceof EntityTrainCore) {
            //for speed change
            if (ClientProxy.KeyAccelerate.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(2, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyReverse.getIsKeyPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(3, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyHorn.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(4, player.ridingEntity.getEntityId()));
            }
        }
    }
}
Also used : EntityTrainCore(ebf.tim.entities.EntityTrainCore) PacketKeyPress(ebf.tim.networking.PacketKeyPress) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) EntitySeat(ebf.tim.entities.EntitySeat) GenericRailTransport(ebf.tim.entities.GenericRailTransport) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)138 EntityPlayer (net.minecraft.entity.player.EntityPlayer)57 ItemStack (net.minecraft.item.ItemStack)48 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)18 Minecraft (net.minecraft.client.Minecraft)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)14 World (net.minecraft.world.World)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)12 ArrayList (java.util.ArrayList)10 EntityItem (net.minecraft.entity.item.EntityItem)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 ChatComponentText (net.minecraft.util.ChatComponentText)8 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)8 Block (net.minecraft.block.Block)7 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)6 AffinityData (am2.playerextensions.AffinityData)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5