Search in sources :

Example 61 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onServerChatEvent.

@SubscribeEvent
public void onServerChatEvent(ServerChatEvent event) {
    SCIRCBot bot = mod_SecurityCraft.instance.getIrcBot(event.getPlayer().getName());
    if (bot != null && bot.getMessageMode()) {
        event.setCanceled(true);
        bot.sendMessage("> " + event.getMessage());
        bot.sendMessageToPlayer(TextFormatting.GRAY + "<" + event.getPlayer().getName() + " --> IRC> " + event.getMessage(), event.getPlayer());
    }
}
Also used : SCIRCBot(net.geforcemods.securitycraft.ircbot.SCIRCBot) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 62 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onPlayerLoggedIn.

@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
    mod_SecurityCraft.instance.createIrcBot(event.player.getName());
    String tipKey = getRandomTip();
    ITextComponent TextComponentString;
    if (tipsWithLink.containsKey(tipKey.split("\\.")[2])) {
        TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
    } else {
        TextComponentString = new TextComponentString("[" + TextFormatting.GOLD + "SecurityCraft" + TextFormatting.WHITE + "] " + I18n.translateToLocal("messages.thanks").replace("#", mod_SecurityCraft.getVersion()) + " " + I18n.translateToLocal("messages.tip") + " " + I18n.translateToLocal(tipKey));
    }
    if (mod_SecurityCraft.configHandler.sayThanksMessage) {
        event.player.addChatComponentMessage(TextComponentString);
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 63 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onBlockBroken.

@SubscribeEvent
public void onBlockBroken(BreakEvent event) {
    if (!event.getWorld().isRemote) {
        if (event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE) {
            CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());
            for (int i = 0; i < te.getNumberOfCustomizableOptions(); i++) {
                if (te.itemStacks[i] != null) {
                    ItemStack stack = te.itemStacks[i];
                    EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
                    event.getWorld().spawnEntityInWorld(item);
                    te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
                    te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[] { stack, ((ItemModule) stack.getItem()).getModule() }, te);
                }
            }
        }
    }
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 64 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project ImmersiveEngineering by BluSunrize.

the class ClientEventHandler method onPlayerTick.

@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    if (event.side.isClient() && event.phase == Phase.START && event.player != null && event.player == ClientUtils.mc().getRenderViewEntity()) {
        skyhookGrabableConnections.clear();
        EntityPlayer player = event.player;
        ItemStack stack = player.getActiveItemStack();
        if (stack != null && stack.getItem() instanceof ItemSkyhook) {
            TileEntity connector = null;
            double lastDist = 0;
            Connection line = null;
            double py = player.posY + player.getEyeHeight();
            BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
            for (int xx = -2; xx <= 2; xx++) for (int zz = -2; zz <= 2; zz++) for (int yy = 0; yy <= 3; yy++) {
                TileEntity tile = player.worldObj.getTileEntity(pos.add(xx, yy, zz));
                if (tile != null) {
                    Connection con = SkylineHelper.getTargetConnection(player.worldObj, pos.add(xx, yy, zz), player, null);
                    if (con != null) {
                        double d = tile.getDistanceSq(player.posX, py, player.posZ);
                        if (connector == null || d < lastDist) {
                            connector = tile;
                            lastDist = d;
                            line = con;
                        }
                    }
                }
            }
            if (line != null && connector != null)
                skyhookGrabableConnections.add(line);
        }
    }
//		if(event.side.isClient() && event.phase == Phase.END && event.player!=null)
//		{
//			EntityPlayer player = event.player;
//			ItemStack stack = player.getActiveItemStack();
//			boolean twohanded = stack!=null && (stack.getItem() instanceof ItemDrill);
//			if(twohanded && (player!=ClientUtils.mc().getRenderViewEntity()||ClientUtils.mc().gameSettings.thirdPersonView!=0))
//			{
//				if(player.getItemInUseCount() <= 0)
//				{
//					player.stopActiveHand();
//					player.setActiveHand(EnumHand.MAIN_HAND);
//				}
//			}
//
//		}
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 65 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project AgriCraft by AgriCraft.

the class GrassDropHandler method interceptGrassDrop.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void interceptGrassDrop(BlockEvent.HarvestDropsEvent event) {
    // Skip silk touch.
    if (event.isSilkTouching()) {
        return;
    }
    // Fetch the blockstate.
    final IBlockState state = event.getState();
    // Skip Air or Error
    if (state == null || state.getBlock() == null) {
        return;
    }
    // Fetch the world random.
    final Random rand = event.getWorld().rand;
    // Add grass drops if grass block.
    if (state.getBlock() instanceof BlockTallGrass) {
        // Wipe other drops, if needed.
        if (AgriCraftConfig.wipeGrassDrops) {
            event.getDrops().clear();
        }
        // Log
        // Commenented out to prevent spam.
        // AgriCore.getLogger("agricraft").debug("Inserting Drops!");
        // Add the drops.
        addGrassDrops(event.getDrops(), rand);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockTallGrass(net.minecraft.block.BlockTallGrass) Random(java.util.Random) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37