Search in sources :

Example 81 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onPlayerTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerTick(PlayerTickEvent event) {
    counter++;
    if (cooldownCounter > 0) {
        cooldownCounter--;
    }
    if (counter >= 20) {
        mod_SecurityCraft.network.sendToServer(new PacketCheckRetinalScanner(event.player.getCommandSenderName()));
        counter = 0;
    }
}
Also used : PacketCheckRetinalScanner(org.freeforums.geforce.securitycraft.network.packets.PacketCheckRetinalScanner) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 82 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onBucketUsed.

@SubscribeEvent
public void onBucketUsed(FillBucketEvent event) {
    ItemStack result = fillBucket(event.world, event.target);
    if (result == null) {
        return;
    }
    event.result = result;
    event.setResult(Result.ALLOW);
}
Also used : ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 83 with SubscribeEvent

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

the class EventManager method entityJoinWorldEvent.

/**
     * <h2>join world</h2>
     * This event is called when a player joins the world, we use this to display the alpha notice, and check for new mod versions, this is only displayed on the client side, but can be used for server..
     */
@SubscribeEvent
@SuppressWarnings("unused")
public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
    if (event.entity instanceof EntityPlayer && event.entity.worldObj.isRemote) {
        //add alpha notice
        ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText("You are currently playing an alpha release of Trains In Motion."));
        ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText("For official releases, check out https://github.com/EternalBlueFlame/Trains-In-Motion/"));
        ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText("Keep in mind that everything in this mod is subject to change, and report any bugs you find."));
        ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText("Good luck and thanks for the assistance. - Eternal Blue Flame."));
        //use an HTTP request and parse to check for new versions of the mod from github.
        try {
            //make an HTTP connection to the version text file, and set the type as get.
            HttpURLConnection conn = (HttpURLConnection) new URL("https://raw.githubusercontent.com/USER/PROJECT/BRANCH/version.txt").openConnection();
            conn.setRequestMethod("GET");
            //use the HTTP connection as an input stream to actually get the file, then put it into a buffered reader.
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            //read the first line of the text document, if it's not the same as the current running version, notify there is an update, then display the second line, which is intended for a download URL.
            if (!TrainsInMotion.MOD_VERSION.equals(rd.readLine())) {
                ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText("A new version of Trains In Motion is available, check it out at:"));
                ((EntityPlayer) event.entity).addChatMessage(new ChatComponentText(rd.readLine()));
            }
        } catch (Exception e) {
        //couldn't check for new version, most likely because there's no internet, so just do nothing.
        }
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText) URL(java.net.URL) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 84 with SubscribeEvent

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

the class ChunkMap method onChunkUnloaded.

@SubscribeEvent
public void onChunkUnloaded(ChunkEvent.Unload event) {
    Chunk chunk = event.getChunk();
    ChunkCoordIntPair coords = chunk.getChunkCoordIntPair();
    if (chunks.containsKey(coords)) {
        //TODO save data
        chunks.remove(coords);
    }
}
Also used : ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Chunk(net.minecraft.world.chunk.Chunk) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 85 with SubscribeEvent

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

the class BPEventHandler method tick.

@SubscribeEvent
public void tick(TickEvent.WorldTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        if (event.world.getWorldTime() % 200 == 0) {
            //In case world are going to get their own thread: MinecraftServer.getServer().worldTickTimes.get(event.world.provider.dimensionId)
            double tickTime = MathHelper.mean(MinecraftServer.getServer().tickTimeArray) * 1.0E-6D;
            BPNetworkHandler.INSTANCE.sendToDimension(new MessageServerTickTime(tickTime), event.world.provider.dimensionId);
        }
    }
}
Also used : MessageServerTickTime(com.bluepowermod.network.message.MessageServerTickTime) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

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