Java Code Examples for cpw.mods.fml.common.eventhandler.SubscribeEvent

The following are top voted examples for showing how to use cpw.mods.fml.common.eventhandler.SubscribeEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PAYDAY   File: MEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onTickEvent(TickEvent.PlayerTickEvent evt) {
	if (tick >= 15) {
		for (TileEntity t : (List<TileEntity>) evt.player.worldObj.loadedTileEntityList) {
			if (t instanceof LobbyTileEntity) {
				tile = (LobbyTileEntity) t;
				
				if (tile.players.size() != tile.blockMetadata)
					tile.check();
			}
		}

		tick = 0;
	}
}
 
Example 2
Project: CreeperHostGui   File: CreeperHostServer.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event)
{
    if (!CreeperHost.instance.active)
        return;
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null || server.isSinglePlayer() || discoverMode != Discoverability.PUBLIC)
        return;

    INetHandlerPlayServer handler = event.handler;
    if (handler instanceof NetHandlerPlayServer)
    {
        EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity;
        playersJoined.add(entity.getUniqueID());
    }
}
 
Example 3
Project: CreeperHostGui   File: EventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onActionPerformed(ActionPerformedEvent.Pre event)
{
    GuiScreen gui = Util.getGuiFromEvent(event);
    GuiButton button = Util.getButton(event);
    if (gui instanceof GuiMainMenu)
    {
        if (button != null && button.id == MAIN_BUTTON_ID)
        {
            Minecraft.getMinecraft().displayGuiScreen(GuiGetServer.getByStep(0, new Order()));
        }
    }
    else if (gui instanceof GuiMultiplayer)
    {
        if (button != null && button.id == MP_BUTTON_ID)
        {
            Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayerPublic(gui));
        }
    }
    else if (gui instanceof GuiIngameMenu && button.id == FRIEND_BUTTON_ID)
    {
        CreeperHost.proxy.openFriendsGui();
    }
}
 
Example 4
Project: CreeperHostGui   File: EventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent event)
{
    if (!Config.getInstance().isSivIntegration())
        return;
    if (event.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST)
    {
        return;
    }
    if (!(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) || Minecraft.getMinecraft().isIntegratedServerRunning() || !guiServerInfo.getIsPlayerOpped())
    {
        return;
    }

    Minecraft mc = Minecraft.getMinecraft();

    ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    guiServerInfo.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
    if (guiServerInfo.renderServerInfo())
    {
        event.setCanceled(true);
    }
}
 
Example 5
Project: ExtraAcC   File: DamageRecalc.java   View source code 6 votes vote down vote up
@SubscribeEvent
  public void recalc(LivingHurtEvent event) {
if (!(event.entity instanceof EntityPlayer)) {
	return;
}
EntityPlayer player = (EntityPlayer) event.entity;
if (!AbilityData.get(player).isSkillLearned(SkillAirControl.INSTANCE)) {
	return;
}
if (event.source.getDamageType().equals("inWall") || event.source.getDamageType().equals("drown")) {
	event.ammount *= 0.1;
} else if (event.source.getDamageType().equals("fall")) {
	event.ammount *= 0.25;
} else if (event.source.isProjectile() || event.source.getDamageType().equals("anvil")) {
	event.ammount *= 0.75;
}
  }
 
Example 6
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
@SuppressWarnings("unchecked")
public void onWorldTick(TickEvent.ServerTickEvent event) {
	if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER)
		return;

	if (EtFuturum.enablePlayerSkinOverlay)
		if (playerLoggedInCooldown != null)
			if (--playerLoggedInCooldown <= 0) {
				for (World world : MinecraftServer.getServer().worldServers)
					for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
						NBTTagCompound nbt = player.getEntityData();
						if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) {
							boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
							EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
						}
					}
				playerLoggedInCooldown = null;
			}
}
 
Example 7
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void arrowNock(ArrowNockEvent event) {
	if (event.result == null)
		return;
	IInventory invt = event.entityPlayer.inventory;
	for (int i = 0; i < invt.getSizeInventory(); i++) {
		ItemStack stack = invt.getStackInSlot(i);
		if (stack == null || stack.stackSize <= 0)
			continue;
		if (stack.getItem() == Items.arrow)
			return;
		if (stack.getItem() == ModItems.tipped_arrow) {
			event.setCanceled(true);
			event.entityPlayer.setItemInUse(event.result, event.result.getItem().getMaxItemUseDuration(event.result));
			return;
		}
	}
}
 
Example 8
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) {
	if (!EtFuturum.enableEnchants)
		return;
	try {
		File file = event.getPlayerFile(Reference.MOD_ID);
		if (!file.exists()) {
			file.createNewFile();
			return;
		}

		BufferedReader br = new BufferedReader(new FileReader(file));
		String line = br.readLine();
		if (line != null) {
			int seed = Integer.parseInt(line);
			ContainerEnchantment.seeds.put(event.playerUUID, seed);
			br.close();
		}
	} catch (Exception e) {
	}
}
 
Example 9
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onPlayerSaveFromFileEvent(PlayerEvent.SaveToFile event) {
	if (!EtFuturum.enableEnchants)
		return;
	try {
		File file = event.getPlayerFile(Reference.MOD_ID);
		if (!file.exists()) {
			file.createNewFile();
			return;
		}

		Integer seed = ContainerEnchantment.seeds.get(event.playerUUID);
		if (seed != null) {
			BufferedWriter bw = new BufferedWriter(new FileWriter(file));
			bw.write(seed.toString());
			bw.close();
		}
	} catch (IOException e) {
	}
}
 
Example 10
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
	if (event.entityLiving.worldObj.isRemote)
		return;

	if (EtFuturum.enableSkullDrop)
		dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);

	Random rand = event.entityLiving.worldObj.rand;
	if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
		int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
		for (int i = 0; i < amount; i++)
			if (event.entityLiving.isBurning())
				addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
			else
				addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
	}
}
 
Example 11
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPig) {
		EntityPig pig = (EntityPig) event.entity;
		if (EtFuturum.enableBeetroot)
			pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
	} else if (event.entity instanceof EntityChicken) {
		EntityChicken chicken = (EntityChicken) event.entity;
		if (EtFuturum.enableBeetroot)
			chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
	} else if (event.entity instanceof EntityWolf) {
		EntityWolf wolf = (EntityWolf) event.entity;
		if (EtFuturum.enableRabbit)
			wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
	} else if (event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		for (Object obj : villager.tasks.taskEntries) {
			EntityAITaskEntry entry = (EntityAITaskEntry) obj;
			if (entry.action instanceof EntityAIOpenDoor) {
				villager.tasks.removeTask(entry.action);
				villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
				break;
			}
		}
	}
}
 
Example 12
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
	if (stack == null)
		return;
	if (!(event.target instanceof EntityAnimal))
		return;

	EntityAnimal animal = (EntityAnimal) event.target;
	if (!animal.isChild()) {
		if (animal instanceof EntityPig) {
			if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
		} else if (animal instanceof EntityChicken)
			if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
	} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
		feedBaby(animal, event.entityPlayer, stack);
}
 
Example 13
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
Example 14
Project: McHeliPrivacyShield   File: CoreHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onScreenShotShield(final @Nonnull ScreenShotShieldEvent.Post event) {
	if (Config.getConfig().notifyChat.get()) {
		final String mode = ScreenShotShieldRegistery.getListener(Config.getConfig().ssmode.get()).name();
		ChatBuilder.create("mchelishield.notification.chat.screenshot.message").useTranslation().setParams(mode).chatClient();
		ChatBuilder.create("mchelishield.notification.chat.screenshot.message.mode").useTranslation().setParams(mode).chatClient();
	}
	if (Config.getConfig().notifySound.get())
		FMLClientHandler.instance().getClient().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("mchelishield", "notification.sound"), 1.0F));
	if (Config.getConfig().notifyEffect.get())
		this.effectStrength = .75f;
	if (Config.getConfig().notifyOverlay.get()) {
		this.text = I18n.format("mchelishield.notification.overlay.screenshot.message");
		this.textStrength = 1f;
	}
}
 
Example 15
Project: McHeliPrivacyShield   File: CoreHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onModListShield(final @Nonnull ModListShieldEvent.Post event) {
	if (Config.getConfig().notifyChat.get()) {
		final String mode = ModListShieldRegistery.getListener(Config.getConfig().mlmode.get()).name();
		ChatBuilder.create("mchelishield.notification.chat.modlist.message").useTranslation().setParams(mode).chatClient();
		ChatBuilder.create("mchelishield.notification.chat.modlist.message.mode").useTranslation().setParams(mode).chatClient();
	}
	if (Config.getConfig().notifySound.get())
		FMLClientHandler.instance().getClient().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("mchelishield", "notification.sound"), 1.0F));
	if (Config.getConfig().notifyEffect.get())
		this.effectStrength = .75f;
	if (Config.getConfig().notifyOverlay.get()) {
		this.text = I18n.format("mchelishield.notification.overlay.modlist.message");
		this.textStrength = 1f;
	}
}
 
Example 16
Project: EasyLogin   File: JoinEvent.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void keyListener(KeyInputEvent event) throws IOException {
	if (EasyLogin.logingui.isPressed()) {
		Minecraft mc = Minecraft.getMinecraft();
		mc.displayGuiScreen(new MainGui(mc.currentScreen));
		// 密码读取
		InputStream in = new BufferedInputStream(new FileInputStream("config/easylogin.properties"));
		prop.load(in);
		// 解密密码
		byte[] passwordByte = prop.getProperty("PassWord").getBytes();
		byte key = 124;
		for (int i = 0; i < passwordByte.length; i++) {
			passwordByte[i] ^= key;
		}
		MainGui.settext(new String(passwordByte));
		System.out.println(new String(passwordByte));
	}
}
 
Example 17
Project: HazardsLib   File: ClientEventHandler.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event)
{
	Minecraft mc = FMLClientHandler.instance().getClient();
	World world = mc.theWorld;
	
	if (event.phase != TickEvent.Phase.START) {
	    if ((Minecraft.getMinecraft().renderViewEntity instanceof EntityPlayer)) {
	    	EntityPlayer player = (EntityPlayer)Minecraft.getMinecraft().renderViewEntity;

	        if ((player != null) && (mc.inGameHasFocus) && (Minecraft.isGuiEnabled())) {
	        	// If player have radiation detector on hotbar.
	        	if (isPlayerHasItemOnHotbar(player.inventory, ItemsHZDS.radiation_detector)) {
        			PlayerTracker tracker = TrackerManager.lookupTrackerFromUsername(mc.thePlayer.getCommandSenderName());
        			
        			if (tracker != null) {
        				renderRadiation(tracker);
        			}
        		}

	        }
	    }
	}
}
 
Example 18
Project: HazardsLib   File: CommonEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event)
{
	PlayerTracker tracker = TrackerManager.lookupTracker(event.original);
	
	if (tracker != null) {
		HazardsLib.modLog.info("Changing tracker owner for: '" + event.entity.getCommandSenderName() + "'...");
		tracker.owner = event.entityPlayer;
		
		if (event.wasDeath) {
			tracker.resetData();
			TrackerManager.saveTracker(tracker);
		}
		
		tracker.loadFromNBT();
	}
	
	if (event.wasDeath) {
		doDeath(event.entityPlayer);
		doDeath(event.original);
	}
}
 
Example 19
Project: minecraft-quiverbow   File: Listener.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void ItemCraftedEvent(cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event)
{
	//System.out.println("[EVENT] Player crafted something.");

	if (event.crafting != null && event.crafting.getItem() instanceof ERA)
	{
		ItemStack stack = event.craftMatrix.getStackInSlot(1);

		if (stack != null && stack.stackSize > 1)
		{
			stack.stackSize -= 26;
			if (stack.stackSize <= 0) { event.craftMatrix.setInventorySlotContents(1, null); }	// Nothing left
		}
		// else, nothing in there or only a single rail, meaning this is a repairing event. I'm fine with that
	}
	// else, not mine, so don't care

	else if (event.crafting != null && event.crafting.getItem() instanceof _WeaponBase)	// More generic weapon check
	{
		this.copyName(event.craftMatrix, event.crafting);
	}
}
 
Example 20
Project: TFCPrimitiveTech   File: CraftingHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onCrafting(ItemCraftedEvent e)
{
	ItemStack itemstack = e.crafting;
	Item item = itemstack.getItem();
	IInventory inventory = e.craftMatrix;
	
	if (item == null || inventory == null) return;
        if(inventory != null)
       	{
            if(item == ModItems.itemWoodenTwig)
       	        com.bioxx.tfc.Handlers.CraftingHandler.handleItem(e.player, e.craftMatrix, Recipes.hammers);
            if(item == TFCItems.stick)
       	        com.bioxx.tfc.Handlers.CraftingHandler.handleItem(e.player, e.craftMatrix, Recipes.knives);
        }


}
 
Example 21
Project: Ye-Olde-Chat   File: ModEventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
    if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) event.entity;

        PlayerRoleplayMode props = PlayerRoleplayMode.get(player);
        NBTTagCompound playerDataRoleplayMode = CommonProxy.getEntityData((player).getCommandSenderName());
        if (playerDataRoleplayMode != null)
        {
            props.loadNBTData(playerDataRoleplayMode);
        }
        
        PacketHandler.INSTANCE.sendTo(new MessageSyncRoleplayMode(player), (EntityPlayerMP) player);
    }
}
 
Example 22
Project: ThaumOres   File: TOEvents.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void eventBreakEvent(BlockEvent.BreakEvent event) {
	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;
	EntityPlayer player = event.getPlayer();

	if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
		if (TOConfig.debugEnable && TOConfig.debugRemover && !world.isRemote
				&& player.capabilities.isCreativeMode) {
			int radius = TOConfig.debugRemoverScannerRadius;
			for (int xx = x - radius; xx < x + radius; xx++)
				for (int zz = z - radius; zz < z + radius; zz++)
					for (int yy = 0; yy < 257; yy++)
						if (!(world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre))
							world.setBlock(xx, yy, zz, Blocks.air, 0, 2);
			String text = "[DEBUG " + ThaumOresMod.NAME + "] Removed blocks at " + x + ";" + z + " with radius "
					+ radius;
			player.addChatMessage(new ChatComponentText(text));
			ThaumOresMod.log.info(text);
		}
	}
}
 
Example 23
Project: TRHS_Club_Mod_2016   File: ForgeModContainer.java   View source code 6 votes vote down vote up
/**
 * By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed.
 * This implementation uses the optional configID string to handle multiple Configurations using one event handler.
 */
@SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event)
{
    if (getMetadata().modId.equals(event.modID) && !event.isWorldRunning)
    {
        if (Configuration.CATEGORY_GENERAL.equals(event.configID))
        {
            syncConfig(false);
        }
        else if ("chunkLoader".equals(event.configID))
        {
            ForgeChunkManager.syncConfigDefaults();
            ForgeChunkManager.loadConfiguration();
        }
    }
}
 
Example 24
Project: ExtraUtilities   File: EventHandlerServer.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void updateEntity(final LivingEvent.LivingUpdateEvent event) {
    if (event.entity.worldObj.isRemote) {
        return;
    }
    if (event.entity.getEntityData().hasKey("CursedEarth")) {
        int c = event.entity.getEntityData().getInteger("CursedEarth");
        if (c == 0) {
            event.entity.setDead();
            NetworkHandler.sendParticle(event.entity.worldObj, "smoke", event.entity.posX, event.entity.posY + event.entity.height / 4.0f, event.entity.posZ, 0.0, 0.0, 0.0, false);
        }
        else {
            --c;
            event.entity.getEntityData().setInteger("CursedEarth", c);
        }
    }
}
 
Example 25
Project: FissionWarfare   File: PlaceStorageEvent.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onBlockPlace(PlaceEvent event) {
	
	Location loc = new Location(event.world, event.x, event.y, event.z);
	TileEntity tileEntity = loc.getTileEntity();
		
	if (tileEntity instanceof TileEntityEnergyBase) {
			
		TileEntityEnergyBase energy = (TileEntityEnergyBase) tileEntity;
			
		NBTTagCompound nbt = NBTUtil.getNBT(event.itemInHand);
			
		if (nbt.hasKey("energy")) {
			energy.storage.modifyEnergyStored(nbt.getInteger("energy"));
		}
	}	
}
 
Example 26
Project: OpenTechnology   File: SimpleComponentTickHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onTick(TickEvent.ServerTickEvent e) {
    if (e.phase == TickEvent.Phase.START) {
        final Runnable[] adds;
        synchronized (pending) {
            adds = pending.toArray(new Runnable[pending.size()]);
            pending.clear();
        }
        for (Runnable runnable : adds) {
            try {
                runnable.run();
            } catch (Throwable t) {
                log.warn("Error in scheduled tick action.", t);
            }
        }
    }
}
 
Example 27
Project: 4Space-5   File: EventHandlerGC.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void schematicFlipEvent(FlipPage event)
{
    ISchematicPage page = null;

    switch (event.direction)
    {
    case 1:
        page = EventHandlerGC.getNextSchematic(event.index);
        break;
    case -1:
        page = EventHandlerGC.getLastSchematic(event.index);
        break;
    }

    if (page != null)
    {
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_OPEN_SCHEMATIC_PAGE, new Object[] { page.getPageID() }));
        FMLClientHandler.instance().getClient().thePlayer.openGui(GalacticraftCore.instance, page.getGuiID(), FMLClientHandler.instance().getClient().thePlayer.worldObj, (int) FMLClientHandler.instance().getClient().thePlayer.posX, (int) FMLClientHandler.instance().getClient().thePlayer.posY, (int) FMLClientHandler.instance().getClient().thePlayer.posZ);
    }
}
 
Example 28
Project: ExtraUtilities   File: TConEvents.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void addUnstableTimer(final SmelteryCastedEvent.CastingTable event) {
    if (ExtraUtils.tcon_unstable_material_id <= 0) {
        return;
    }
    final ItemStack output = event.output;
    if (output == null || !(output.getItem() instanceof IToolPart)) {
        return;
    }
    final IToolPart part = (IToolPart)output.getItem();
    if (part.getMaterialID(output) != ExtraUtils.tcon_unstable_material_id) {
        return;
    }
    final NBTTagCompound tag = getOrInitTag(output);
    final WorldServer world = DimensionManager.getWorld(0);
    if (world == null) {
        return;
    }
    tag.setLong("XUDeadline", world.getTotalWorldTime());
    final WorldServer localWorld = DimensionManager.getWorld(this.curDim);
    if (localWorld != null) {
        tag.setLong("XULocalDeadline", localWorld.getTotalWorldTime());
        tag.setInteger("XULocalDim", this.curDim);
    }
}
 
Example 29
Project: ExtraUtilities   File: TConEvents.java   View source code 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void denyCraft(final ToolBuildEvent event) {
    if (ExtraUtils.tcon_unstable_material_id <= 0) {
        return;
    }
    final WorldServer world = DimensionManager.getWorld(0);
    if (world == null) {
        return;
    }
    if (isToolExpired(event.headStack, world) || isToolExpired(event.handleStack, world) || isToolExpired(event.accessoryStack, world) || isToolExpired(event.extraStack, world)) {
        event.headStack = null;
        event.handleStack = null;
        event.accessoryStack = null;
        event.extraStack = null;
    }
}
 
Example 30
Project: WorldBorder-Forge   File: EnderPearlListener.java   View source code 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerPearl(EnderTeleportEvent event)
{
    if ( !(event.entityLiving instanceof EntityPlayerMP) )
        return;

    if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() )
        return;

    EntityPlayerMP player = (EntityPlayerMP) event.entityLiving;
    Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() );

    Location target = new Location(event, player);
    Location newLoc = BorderCheck.checkPlayer(player, target, true, true);

    if (newLoc != null)
    {
        event.setCanceled(true);
        event.targetX = newLoc.posX;
        event.targetY = newLoc.posY;
        event.targetZ = newLoc.posZ;
    }
}
 
Example 31
Project: ExtraUtilities   File: EventHandlerUnderdark.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void noMobs(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.DEFAULT && event.world.provider.dimensionId == ExtraUtils.underdarkDimID && event.entity instanceof EntityMob) {
        if (EventHandlerUnderdark.rand.nextDouble() < Math.min(0.95, event.entity.posY / 80.0)) {
            event.setResult(Event.Result.DENY);
        }
        else {
            IAttributeInstance t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.maxHealth);
            t.setBaseValue(t.getBaseValue() * 2.0);
            ((EntityMob)event.entity).heal((float)t.getAttributeValue());
            t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.attackDamage);
            t.setBaseValue(t.getBaseValue() * 2.0);
            if (!EventHandlerServer.isInRangeOfTorch(event.entity) && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
                event.setResult(Event.Result.ALLOW);
            }
        }
    }
}
 
Example 32
Project: 4Space-5   File: TransmitterNetworkRegistry.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event)
{
	if(event.getChunk() != null && !event.world.isRemote)
	{
		int x = event.getChunk().xPosition;
		int z = event.getChunk().zPosition;

		IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider();
		Chunk[] neighbors = new Chunk[5];

		neighbors[0] = event.getChunk();

		if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z);
		if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z);
		if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1);
		if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1);

		for(Chunk c : neighbors)
		{
			refreshChunk(c);
		}
	}
}
 
Example 33
Project: 4Space-5   File: EventHandlerGC.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onZombieSummonAid(SummonAidEvent event)
{
    if (event.entity instanceof EntityEvolvedZombie)
    {
        event.customSummonedAid = new EntityEvolvedZombie(event.world);

        if (((EntityLivingBase) event.entity).getRNG().nextFloat() < ((EntityEvolvedZombie) event.entity).getEntityAttribute(((EntityEvolvedZombie) event.entity).getReinforcementsAttribute()).getAttributeValue())
        {
            event.setResult(Result.ALLOW);
        }
        else
        {
            event.setResult(Result.DENY);
        }
    }
}
 
Example 34
Project: 4Space-5   File: MarsModuleClient.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event)
{
    final Minecraft minecraft = FMLClientHandler.instance().getClient();

    final WorldClient world = minecraft.theWorld;

    if (world != null)
    {
        if (world.provider instanceof WorldProviderMars)
        {
            if (world.provider.getSkyRenderer() == null)
            {
                world.provider.setSkyRenderer(new SkyProviderMars((IGalacticraftWorldProvider) world.provider));
            }

            if (world.provider.getCloudRenderer() == null)
            {
                world.provider.setCloudRenderer(new CloudRenderer());
            }
        }
    }
}
 
Example 35
Project: 4Space-5   File: EventHandlerMars.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onPlanetDecorated(GCCoreEventPopulate.Post event)
{
    if (this.eggGenerator == null)
    {
        this.eggGenerator = new WorldGenEggs(MarsBlocks.rock);
    }

    if (event.worldObj.provider instanceof WorldProviderMars)
    {
        int eggsPerChunk = 2;
        int x;
        int y;
        int z;

        for (int eggCount = 0; eggCount < eggsPerChunk; ++eggCount)
        {
            x = event.chunkX + event.rand.nextInt(16) + 8;
            y = event.rand.nextInt(128);
            z = event.chunkZ + event.rand.nextInt(16) + 8;
            this.eggGenerator.generate(event.worldObj, event.rand, x, y, z);
        }
    }
}
 
Example 36
Project: 4Space-5   File: ConnectionEvents.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onConnectionReceived(ServerConnectionFromClientEvent event)
{
    if (ConfigManagerCore.enableDebug)
    {
    	Integer[] idList = (Integer[]) WorldUtil.getPlanetList().get(0);
    	String ids = "";
    	for (int j = 0; j < idList.length; j++)
    	{
   			ids+=idList[j].toString()+" ";
    	}
    	GCLog.info("Galacticraft server sending dimension IDs to connecting client: "+ ids);
    }
    event.manager.scheduleOutboundPacket(ConnectionPacket.createDimPacket(WorldUtil.getPlanetListInts()));
    event.manager.scheduleOutboundPacket(ConnectionPacket.createSSPacket(WorldUtil.getSpaceStationListInts()));
    event.manager.scheduleOutboundPacket(ConnectionPacket.createConfigPacket(ConfigManagerCore.getServerConfigOverride()));
}
 
Example 37
Project: RFUtilities   File: EventHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void entityEvent(LivingEvent.LivingUpdateEvent event)
{
    if (event.entity instanceof EntityPlayer)
    {
        if (((EntityPlayer) event.entity).getCurrentEquippedItem() != null)
        {
            canItemShowTess =
                    (RFUtilities.TE_LOADED && (((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemToolBase ||
                    ((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemMultimeter)) ||
                    ((EntityPlayer) event.entity).getCurrentEquippedItem().getItem() instanceof ItemDialer;
        }
        else
        {
            canItemShowTess = false;
        }
    }
}
 
Example 38
Project: PAYDAY   File: MEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone e) {
	NBTTagCompound nbt = new NBTTagCompound();
	
	PlayerData.get(e.original).saveReviveRelevantNBTData(nbt, e.wasDeath);
	PlayerData.get(e.entityPlayer).loadNBTData(nbt);
}
 
Example 39
Project: PAYDAY   File: MEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent evt) {
	/*
	if (evt.block instanceof LobbyBlock) {
		// RESETS DATA AND CANCELS EVENT
		LobbyTileEntity t = (LobbyTileEntity) evt.world.getTileEntity(evt.x, evt.y, evt.z);

		if (t != null) {
			PlayerData data;
			
			for (EntityPlayer p : UUIDUtil.getPlayersFromProfileUUIDs(evt.world, t.players)) {
				data = PlayerData.get(p);
				
				data.setReady(false);
				data.setInLobby(false);
				
				if (evt.world.isRemote)
					data.sendToServer();
				
				t.removePlayer(p);
				
				//PAYDAY.INSTANCE.sendToServer(new LobbyPlayerActionPacket(evt.x, evt.y, evt.z, true));
			}
		}
		//evt.setCanceled(true);
	}*/
}
 
Example 40
Project: nei-lotr   File: FMLEventHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
	if (mod.getConfig().isUseVersionChecker() && mod.getVersionChecker().isNewVersionAvaible()) {
		if (mod.getVersionChecker().getNewestVersion() != null) {
			event.player.addChatComponentMessage(mod.getVersionChecker().getNewestVersion().getFormattedChatText());
		}
	}

}