当前位置: 首页>>代码示例>>Java>>正文


Java SubscribeEvent类代码示例

本文整理汇总了Java中cpw.mods.fml.common.eventhandler.SubscribeEvent的典型用法代码示例。如果您正苦于以下问题:Java SubscribeEvent类的具体用法?Java SubscribeEvent怎么用?Java SubscribeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SubscribeEvent类属于cpw.mods.fml.common.eventhandler包,在下文中一共展示了SubscribeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActionPerformed

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:25,代码来源:EventHandler.java

示例2: onTickEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:TominoCZ,项目名称:PAYDAY,代码行数:16,代码来源:MEventHandler.java

示例3: clientConnectedtoServer

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:17,代码来源:CreeperHostServer.java

示例4: onRenderGameOverlay

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:24,代码来源:EventHandler.java

示例5: recalc

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
}
  }
 
开发者ID:Kanbe-Kotori,项目名称:ExtraAcC,代码行数:18,代码来源:DamageRecalc.java

示例6: onWorldTick

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
			}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:21,代码来源:ServerEventHandler.java

示例7: arrowNock

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:19,代码来源:ServerEventHandler.java

示例8: onPlayerLoadFromFileEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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) {
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:22,代码来源:ServerEventHandler.java

示例9: onPlayerSaveFromFileEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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) {
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:21,代码来源:ServerEventHandler.java

示例10: dropEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:19,代码来源:ServerEventHandler.java

示例11: spawnEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:27,代码来源:ServerEventHandler.java

示例12: interactEntityEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:20,代码来源:ServerEventHandler.java

示例13: entityHurtEvent

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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));
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:26,代码来源:ServerEventHandler.java

示例14: onScreenShotShield

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:Team-Fruit,项目名称:McHeliPrivacyShield,代码行数:17,代码来源:CoreHandler.java

示例15: onModListShield

import cpw.mods.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:Team-Fruit,项目名称:McHeliPrivacyShield,代码行数:17,代码来源:CoreHandler.java


注:本文中的cpw.mods.fml.common.eventhandler.SubscribeEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。