當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityJoinWorldEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.EntityJoinWorldEvent的典型用法代碼示例。如果您正苦於以下問題:Java EntityJoinWorldEvent類的具體用法?Java EntityJoinWorldEvent怎麽用?Java EntityJoinWorldEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityJoinWorldEvent類屬於net.minecraftforge.event.entity包,在下文中一共展示了EntityJoinWorldEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntityJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
	{
		EntityLivingBase entity = (EntityLivingBase) event.getEntity();
		World world = entity.getEntityWorld();
		IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		
		if (enemyLevelCap != null && chunkLevelHolder != null)
		{
			if (enemyLevelCap.getEnemyLevel() == 0)
			{
				IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
				int level = chunkLevel.getChunkLevel();
				
				enemyLevelCap.setEnemyLevel(level);
				entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
				
				if (level > 1) setAttributeModifiers(entity, level);
			}
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:26,代碼來源:EventEntityJoinWorld.java

示例2: onEntityJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.isOnJoin() && rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Join Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getEntity().getPosition().getY());
            }
            if (result != Event.Result.DENY) {
                rule.action(event);
            } else {
                event.setCanceled(true);
            }
            return;
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:22,代碼來源:ForgeEventHandlers.java

示例3: entityJoinedWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void entityJoinedWorld(EntityJoinWorldEvent event)
{
    if (playersJoined.contains(event.getEntity().getUniqueID()))
    {
        EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
        logger.info("Sending ID packet to client {}", entity.getName());
        PacketHandler.INSTANCE.sendTo(new PacketHandler.ServerIDMessage(updateID), entity);

        for (PregenTask task : pregenTasks.values())
        {
            if (task.preventJoin)
            {
                kicker.kickPlayer(entity, "Server is still pre-generating!\n" + task.lastPregenString);
                logger.error("Kicked player " + entity.getName() + " as still pre-generating");
                break;
            }
        }
        playersJoined.remove(entity.getUniqueID());
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:22,代碼來源:CreeperHostServer.java

示例4: spawnEvent

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的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

示例5: onSpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onSpawn(EntityJoinWorldEvent event) {
	if (TF2ConfigVars.targetSentries && event.getEntity() instanceof IMob && event.getEntity() instanceof EntityCreature) {
		((EntityCreature)event.getEntity()).targetTasks.addTask(100, 
				new EntityAINearestAttackableTarget<EntitySentry>((EntityCreature) event.getEntity(), EntitySentry.class, 10, true, false, sentry -> {
			return sentry.getOwnerId() != null;
		}) {
			protected double getTargetDistance()
		    {
		        return super.getTargetDistance() * 0.45f;
		    }
		});
	}
	if (event.getEntity() instanceof EntityPlayer){
		if (event.getEntity().world.isRemote) {
			if (event.getEntity() == ClientProxy.getLocalPlayer())
				TF2weapons.network.sendToServer(new TF2Message.InitClientMessage(TF2weapons.conf));
			TF2weapons.network.sendToServer(new TF2Message.ActionMessage(99, (EntityLivingBase) event.getEntity()));
		}
		if (event.getEntity().world != null && !event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayerMP){
			EntityPlayerMP player=((EntityPlayerMP)event.getEntity());
			player.inventoryContainer.addListener(new TF2ContainerListener(player));
		}
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:26,代碼來源:TF2EventsCommon.java

示例6: onEntityJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:Zundrel,項目名稱:Ye-Olde-Chat,代碼行數:18,代碼來源:ModEventHandler.java

示例7: recreateGoldenBags

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void recreateGoldenBags(final EntityJoinWorldEvent event) {
    if (event.world.isRemote || ExtraUtils.goldenBag == null) {
        return;
    }
    if (event.entity instanceof EntityPlayer && event.entity.getEntityData().hasKey("PlayerPersisted") && event.entity.getEntityData().getCompoundTag("PlayerPersisted").hasKey("XU|GoldenBags")) {
        final NBTTagCompound tags = event.entity.getEntityData().getCompoundTag("PlayerPersisted").getCompoundTag("XU|GoldenBags");
        for (int n = tags.getInteger("no_items"), i = 0; i < n; ++i) {
            final ItemStack item = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("item_" + i));
            if (item != null) {
                ((EntityPlayer)event.entity).inventory.addItemStackToInventory(ItemGoldenBag.clearMagic(item));
            }
        }
        event.entity.getEntityData().getCompoundTag("PlayerPersisted").removeTag("XU|GoldenBags");
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:17,代碼來源:EventHandlerServer.java

示例8: Siege

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void Siege(final EntityJoinWorldEvent event) {
    if (event.world.isRemote) {
        return;
    }
    checkPlayers();
    if (event.entity instanceof EntityPlayer) {
        if (event.world.provider.dimensionId != 1) {
            if (event.entity.getEntityData().hasKey("SiegeKills")) {
                event.entity.getEntityData().removeTag("SiegeKills");
                EventHandlerSiege.SiegeParticipants.remove(((EntityPlayer)event.entity).getGameProfile().getName());
            }
        }
        else if (event.entity.getEntityData().hasKey("SiegeKills") && !EventHandlerSiege.SiegeParticipants.contains(((EntityPlayer)event.entity).getGameProfile().getName())) {
            EventHandlerSiege.SiegeParticipants.add(((EntityPlayer)event.entity).getGameProfile().getName());
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:19,代碼來源:EventHandlerSiege.java

示例9: onEntityJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();
    World world = event.getWorld();

    if(entity instanceof EntityItem)
    {
        ItemStack stack = ((EntityItem) entity).getEntityItem();
        if(!stack.isEmpty() && isRottingItem(stack))
        {
            if(!entity.isDead)
                TrackedItemsAdd.add((EntityItem)entity);
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:17,代碼來源:RotHandler.java

示例10: onJoinEvent

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onJoinEvent(EntityJoinWorldEvent event){
    if(event.getEntity() == Minecraft.getMinecraft().player) {

        if(!event.getEntity().isDead) {
            String message = I18n.translateToLocal("chat.join");

            message = message.replace("%tag%", I18n.translateToLocal("chat.tag"));
            message = message.replace("%loaded%", Layer.getActiveKeys().size()+"");
            message = message.replace("%total%", MacroKey.instance.boundKeys.size()+"");

            if(MacroKey.instance.configuration.getBoolean("isSpawnMessageEnabled",MacroKey.instance.configuration.CATEGORY_GENERAL, true, "set this to false if you are getting annoyed by the spam")) {
                Minecraft.getMinecraft().player.sendChatMessage(message);
            }
            MacroKey.instance.configuration.save();
        }
    }
}
 
開發者ID:Matts,項目名稱:MacroKey,代碼行數:20,代碼來源:WorldEvents.java

示例11: playerJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void playerJoin(EntityJoinWorldEvent event) {
	if (event.getEntity() instanceof EntityPlayer && !event.getWorld().isRemote) {		
		ExtendedPlayer ePlayer = ExtendedPlayerProvider.getExtendedPlayer((EntityPlayer) event.getEntity());	
		ExtendedPlayerInventory inventory = ePlayer.getInventory();
		for (int a=0;a<inventory.getSlots();a++) inventory.setChanged(a,true);
		
		for (EntityPlayer p : event.getEntity().getEntityWorld().playerEntities) {
			if (p.getEntityId() != event.getEntity().getEntityId()) {
				ExtendedPlayer ePlayer2 = ExtendedPlayerProvider.getExtendedPlayer(p);
				ExtendedPlayerInventory inventory2 = ePlayer2.getInventory();	
				for (int a=0;a<inventory2.getSlots();a++) inventory2.setChanged(a,true);
			}
		}
		
		String[] ia = new String[inventory.getSlots()];
		Arrays.fill(ia, "");
		syncCheck.put(event.getEntity().getCachedUniqueIdString(), ia);		
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:21,代碼來源:EventHandler.java

示例12: onPlayerSpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
/**
 * On player's spawn in the world (when player travels in other dimension 
 * and spawns there or when player dies and then respawns).
 * 
 * This method is responsible for sending morphing data on the client.
 */
@SubscribeEvent
public void onPlayerSpawn(EntityJoinWorldEvent event)
{
    if (event.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) event.getEntity();

        if (!player.worldObj.isRemote)
        {
            IMorphing morphing = Morphing.get(player);

            this.sendAcquiredMorphs(morphing, player);
        }
    }
}
 
開發者ID:mchorse,項目名稱:metamorph,代碼行數:22,代碼來源:CapabilityHandler.java

示例13: redstoneHandler

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void redstoneHandler(EntityJoinWorldEvent event) {
	if (event.getWorld().isRemote)
	{
		return;
	}
	
	if (event.getEntity() instanceof EntityItem && !(event.getEntity() instanceof EntityBurnableItem))
	{
		EntityItem item = (EntityItem) event.getEntity();
		if (EntityBurnableItem.isBurnable(item.getItem()))
		{
			EntityBurnableItem newItem = new EntityBurnableItem(event.getWorld(), item.posX, item.posY, item.posZ, item.getItem());
			newItem.motionX = item.motionX;
			newItem.motionY = item.motionY;
			newItem.motionZ = item.motionZ;
			newItem.setDefaultPickupDelay();
			item.setDead();
			event.getWorld().spawnEntity(newItem);
		}
	}
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:23,代碼來源:EventHandler.java

示例14: PlayerJoinedWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
/**
 * This event is used to determine if the player should be given the starting house item when they log in.
 * @param event The event object.
 */
@SubscribeEvent
public static void PlayerJoinedWorld(EntityJoinWorldEvent event)
{
	if (!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayerMP) 
	{
		System.out.println("Player joined world, checking to see if the house builder should be provided.");

		EntityPlayerMP player = (EntityPlayerMP)event.getEntity();
		EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData((EntityPlayerMP)event.getEntity());
		
		if (!playerConfig.givenHouseBuilder && Prefab.proxy.proxyConfiguration.addHouseItem)
		{
			ItemStack stack = Prefab.proxy.proxyConfiguration.addModerateHouseInstead ? new ItemStack(ModRegistry.ModerateHouse()) : new ItemStack(ModRegistry.StartHouse());
			player.inventory.addItemStackToInventory(stack);
			player.inventoryContainer.detectAndSendChanges();

			// Make sure to set the tag for this player so they don't get the item again.
			playerConfig.givenHouseBuilder = true;
			playerConfig.saveToPlayer(player);
		}
		
		// Send the persist tag to the client.
		Prefab.network.sendTo(new PlayerEntityTagMessage(playerConfig.getModIsPlayerNewTag(player)), player);
	}
}
 
開發者ID:Brian-Wuest,項目名稱:MC-Prefab,代碼行數:30,代碼來源:ModEventHandler.java

示例15: onWorldJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入依賴的package包/類
@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent e) {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
        InventorySaveHandler.init();
        if (e.getEntity() instanceof EntityPlayer) {
            ClientProxy.player = FMLClientHandler.instance().getClientPlayerEntity();
            if (((EntityPlayer) e.getEntity()).capabilities.isCreativeMode) {
                JEIButtons.btnGameMode = btnGameMode.cycle();
            } else {
                JEIButtons.btnGameMode = EnumButtonCommands.CREATIVE;
            }
        }
    } else {
        if (e.getEntity() != null && e.getEntity() instanceof EntityPlayerMP)
            CommonProxy.INSTANCE.sendTo(new MessageNotifyClient(), (EntityPlayerMP) e.getEntity());
    }
}
 
開發者ID:univrsal,項目名稱:JustEnoughButtons,代碼行數:18,代碼來源:EventHandlers.java


注:本文中的net.minecraftforge.event.entity.EntityJoinWorldEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。