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


Java EntityJoinWorldEvent.getEntity方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.EntityJoinWorldEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityJoinWorldEvent.getEntity方法的具体用法?Java EntityJoinWorldEvent.getEntity怎么用?Java EntityJoinWorldEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.EntityJoinWorldEvent的用法示例。


在下文中一共展示了EntityJoinWorldEvent.getEntity方法的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: 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

示例3: 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

示例4: checkSpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void checkSpawn (EntityJoinWorldEvent event) {

    if (event.getEntity() instanceof EntitySlime && !event.getEntity().hasCustomName()) {

        for (final TileEntity tile : event.getWorld().loadedTileEntityList) {

            if (tile instanceof TileEntityAntiSlime && ((TileEntityAntiSlime) tile).shareChunks((EntityLivingBase) event.getEntity())) {

                if (event.getWorld().isBlockPowered(tile.getPos())) {
                    continue;
                }

                event.setCanceled(true);
                event.getEntity().setDead();
                break;
            }
        }
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Dark-Utilities,代码行数:21,代码来源:FeatureAntiSlime.java

示例5: 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

示例6: 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

示例7: entityJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void entityJoinWorld(EntityJoinWorldEvent event)
{
    Entity e = event.getEntity();
    if (e instanceof EntityPlayer && !e.getEntityWorld().isRemote)
    {
        for (String g : giveOnFirstJoin)
        {
            String tag = MODID + ":givenBook:" + g;
            if (!e.getTags().contains(tag))
            {
                ItemHandlerHelper.giveItemToPlayer((EntityPlayer) e, guidebook.of(new ResourceLocation(g)));
                e.addTag(tag);
            }
        }
    }
}
 
开发者ID:gigaherz,项目名称:Guidebook,代码行数:18,代码来源:GuidebookMod.java

示例8: onEntitySpawn

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
    if(event.getEntity().world.isRemote)
    {
        Minecraft mc = Minecraft.getMinecraft();
        if(event.getEntity() instanceof EntityFishHook)
        {
            fishHooks.add((EntityFishHook)event.getEntity());
        }
        if(event.getEntity() instanceof EntityZombie && !(event.getEntity() instanceof EntityZombieVillager) || event.getEntity() instanceof EntitySkeleton || MobAmputation.config.playerGibs == 1 && event.getEntity() instanceof EntityPlayer && event.getEntity() != mc.player)
        {
            EntityLivingBase living = (EntityLivingBase)event.getEntity();
            if(!amputationMap.containsKey(living) && !living.isChild())
            {
                attachGibs(event.getEntity().world, living);
            }
        }
    }
}
 
开发者ID:iChun,项目名称:Mob-Amputation,代码行数:21,代码来源:EventHandlerClient.java

示例9: 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

示例10: onJoinWorld

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityPlayer && !event.getEntity().getEntityData().hasKey("hasSpawned"))
	{
		/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
			((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/

		//((EntityPlayer)event.getEntity()).getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1000);
		//((EntityPlayer)event.getEntity()).setHealth(1000);
		event.getEntity().getEntityData().setBoolean("hasSpawned", true);
	}

	if (event.getEntity() instanceof EntityPlayer)
	{
		/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
			((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/

		((EntityPlayer)event.getEntity()).inventoryContainer = new ContainerPlayerTFC(((EntityPlayer)event.getEntity()).inventory, !event.getWorld().isRemote, (EntityPlayer)event.getEntity());
		((EntityPlayer)event.getEntity()).openContainer = ((EntityPlayer)event.getEntity()).inventoryContainer;
		if(!event.getWorld().isRemote)
		{
			TFC.network.sendTo(new CFoodPacket((IFoodStatsTFC)((EntityPlayer)event.getEntity()).getFoodStats()), (EntityPlayerMP)event.getEntity());
		}
	}
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:27,代码来源:JoinWorldHandler.java

示例11: applyForgeEventPatch

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@Override
public <T extends Event> boolean applyForgeEventPatch(T e) {
	EntityJoinWorldEvent event = (EntityJoinWorldEvent) e;
	
	EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
	AppliedPatches patches = PatchManager.instance().getAppliedPatchesForPlayer(player);
	
	if (player.connection.player == event.getEntity() && !(player.connection instanceof NetHandlerPlayServer)) {
		net.minecraft.network.NetHandlerPlayServer handler = player.connection;
		player.connection = new NetHandlerPlayServer(player.getServer(), handler.netManager, handler.player);
		
		if (patches != null) 
			patches.setPatchSuccessfullyApplied(this.displayName, true);
	}
	
	return true;
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:18,代码来源:PatchNetHandlerPlayServer.java

示例12: sendAlert

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void sendAlert(EntityJoinWorldEvent event) {
	if (!(event.getEntity() instanceof EntityCreeper)) {
		return;
	}

	List players = event.getEntity().worldObj.playerEntities;

	for (int i = 0; i < players.size(); i++) {
		EntityPlayer player = (EntityPlayer) players.get(i);
		if (event.getWorld().isRemote) {
			player.addChatComponentMessage(new TextComponentString(
					TextFormatting.GREEN + "A creeper has spawned!"));
		}
	}
}
 
开发者ID:jarryDk,项目名称:MineCraft,代码行数:17,代码来源:CreeperSpawnAlert.java

示例13: onPlayerLogin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
        AllomancyCapability cap = AllomancyCapability.forPlayer(player);
        Registry.network.sendTo(new AllomancyCapabilityPacket(cap, event.getEntity().getEntityId()), player);
        if (cap.getAllomancyPower() >= 0) {
            Registry.network.sendTo(new AllomancyCapabilityPacket(cap, player.getEntityId()), player);
        } else if (AllomancyConfig.randomizeMistings && cap.getAllomancyPower() == -1) {

            int randomMisting = (int) (Math.random() * 8);

            cap.setAllomancyPower(randomMisting);
            Registry.network.sendTo(new AllomancyPowerPacket(randomMisting), player);
            ItemStack dust = new ItemStack(Item.getByNameOrId("allomancy:flake" + Registry.flakeMetals[randomMisting]));
            // Give the player one flake of their metal
            if (!player.inventory.addItemStackToInventory(dust)) {
                EntityItem entity = new EntityItem(event.getEntity().getEntityWorld(), player.posX, player.posY, player.posZ, dust);
                event.getEntity().getEntityWorld().spawnEntity(entity);
            }
        }
    }
}
 
开发者ID:legobmw99,项目名称:Allomancy,代码行数:24,代码来源:CommonEventHandler.java

示例14: onJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onJoin(EntityJoinWorldEvent event) {
	if (!event.getWorld().isRemote) {
		if (event.getEntity() instanceof EntityPlayer) {
			EntityPlayer player = (EntityPlayer) event.getEntity();
			if (names.contains(player.getDisplayName())) {
				ItemStack potato = new ItemStack(Items.POISONOUS_POTATO);
				potato.addEnchantment(Enchantments.UNBREAKING, 1);
				potato.setStackDisplayName("Death Potato");
				if (!player.inventory.hasItemStack(potato)) {
					player.inventory.addItemStackToInventory(potato);
				}
			}
		}
	}
}
 
开发者ID:Vanhal,项目名称:ProgressiveAutomation,代码行数:17,代码来源:EventPlayers.java

示例15: onEntityJoin

import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
/**
 * Crash the game if our inventory has been replaced by something else, or the coremod failed
 * Also synchronize battle inventory
 * @param event that spawned the player
 */
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityJoin(EntityJoinWorldEvent event){
    if (isValid(event.getEntity())) {
        if (!(((EntityPlayer) event.getEntity()).inventory instanceof InventoryPlayerBattle) && !MinecraftForge.EVENT_BUS.post(new InventoryExceptionEvent((EntityPlayer)event.getEntity()))) {
            throw new RuntimeException("Player inventory has been replaced with " + ((EntityPlayer) event.getEntity()).inventory.getClass() + " which is incompatible with Mine & Blade:Battlegear.");
        }
        if(event.getEntity() instanceof EntityPlayerMP){
            Battlegear.packetHandler.sendPacketToPlayer(
                    new BattlegearSyncItemPacket((EntityPlayer) event.getEntity()).generatePacket(),
                    (EntityPlayerMP) event.getEntity());

        }
    }
    if (event.getEntity() instanceof EntityLivingBase) {
        ((EntityLivingBase) event.getEntity()).getEntityAttribute(Attributes.daze).setBaseValue(0);
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:23,代码来源:BattlemodeHookContainerClass.java


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