当前位置: 首页>>代码示例>>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;未经允许,请勿转载。