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


Java Entity.setEntityId方法代碼示例

本文整理匯總了Java中net.minecraft.entity.Entity.setEntityId方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.setEntityId方法的具體用法?Java Entity.setEntityId怎麽用?Java Entity.setEntityId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.Entity的用法示例。


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

示例1: addEntityToWorld

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Add an ID to Entity mapping to entityHashSet
 */
public void addEntityToWorld(int p_73027_1_, Entity p_73027_2_)
{
    Entity entity = this.getEntityByID(p_73027_1_);

    if (entity != null)
    {
        this.removeEntity(entity);
    }

    this.entityList.add(p_73027_2_);
    p_73027_2_.setEntityId(p_73027_1_);

    if (!this.spawnEntityInWorld(p_73027_2_))
    {
        this.entitySpawnQueue.add(p_73027_2_);
    }

    this.entitiesById.addKey(p_73027_1_, p_73027_2_);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:WorldClient.java

示例2: addEntityToWorld

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Add an ID to Entity mapping to entityHashSet
 */
public void addEntityToWorld(int entityID, Entity entityToSpawn)
{
    Entity entity = this.getEntityByID(entityID);

    if (entity != null)
    {
        this.removeEntity(entity);
    }

    this.entityList.add(entityToSpawn);
    entityToSpawn.setEntityId(entityID);

    if (!this.spawnEntityInWorld(entityToSpawn))
    {
        this.entitySpawnQueue.add(entityToSpawn);
    }

    this.entitiesById.addKey(entityID, entityToSpawn);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:23,代碼來源:WorldClient.java

示例3: handleSpawnExperienceOrb

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Spawns an experience orb and sets its value (amount of XP)
 */
public void handleSpawnExperienceOrb(S11PacketSpawnExperienceOrb packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = new EntityXPOrb(this.clientWorldController, (double)packetIn.getX() / 32.0D, (double)packetIn.getY() / 32.0D, (double)packetIn.getZ() / 32.0D, packetIn.getXPValue());
    entity.serverPosX = packetIn.getX();
    entity.serverPosY = packetIn.getY();
    entity.serverPosZ = packetIn.getZ();
    entity.rotationYaw = 0.0F;
    entity.rotationPitch = 0.0F;
    entity.setEntityId(packetIn.getEntityID());
    this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:NetHandlerPlayClient.java

示例4: handleSpawnExperienceOrb

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Spawns an experience orb and sets its value (amount of XP)
 */
public void handleSpawnExperienceOrb(S11PacketSpawnExperienceOrb packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Entity entity = new EntityXPOrb(this.clientWorldController, (double) packetIn.getX() / 32.0D,
			(double) packetIn.getY() / 32.0D, (double) packetIn.getZ() / 32.0D, packetIn.getXPValue());
	entity.serverPosX = packetIn.getX();
	entity.serverPosY = packetIn.getY();
	entity.serverPosZ = packetIn.getZ();
	entity.rotationYaw = 0.0F;
	entity.rotationPitch = 0.0F;
	entity.setEntityId(packetIn.getEntityID());
	this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:NetHandlerPlayClient.java

示例5: handleSpawnExperienceOrb

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Spawns an experience orb and sets its value (amount of XP)
 */
public void handleSpawnExperienceOrb(SPacketSpawnExperienceOrb packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    double d0 = packetIn.getX();
    double d1 = packetIn.getY();
    double d2 = packetIn.getZ();
    Entity entity = new EntityXPOrb(this.clientWorldController, d0, d1, d2, packetIn.getXPValue());
    EntityTracker.updateServerPosition(entity, d0, d1, d2);
    entity.rotationYaw = 0.0F;
    entity.rotationPitch = 0.0F;
    entity.setEntityId(packetIn.getEntityID());
    this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity);
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:17,代碼來源:NetHandlerPlayClient.java

示例6: processTrackerUpdate

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private void processTrackerUpdate(PacketCustom packet, WorldClient world, EntityPlayer player) {
    int entityID = packet.readInt();
    int freq = packet.readUShort();
    boolean attached = packet.readBoolean();

    Entity e = world.getEntityByID(entityID);
    if (e != null && e.isDead)
        e = null;

    if (!(e instanceof EntityWirelessTracker)) {
        if (e != null)
            throw new IllegalStateException("EntityID mapped to non tracker");

        e = new EntityWirelessTracker(world, freq);
        e.setEntityId(entityID);
        world.addEntityToWorld(entityID, e);
    }
    EntityWirelessTracker tracker = (EntityWirelessTracker) e;

    if (attached) {
        int attachedEntityID = packet.readInt();

        Entity attachedEntity;
        if (attachedEntityID == player.getEntityId())
            attachedEntity = player;
        else
            attachedEntity = world.getEntityByID(attachedEntityID);

        if (attachedEntity == null) {
            return;
        }

        tracker.attached = true;
        tracker.attachedEntity = attachedEntity;
        tracker.attachedX = packet.readFloat();
        tracker.attachedY = packet.readFloat();
        tracker.attachedZ = packet.readFloat();
        tracker.attachedYaw = packet.readFloat();
    } else {
        tracker.attachedEntity = null;
        tracker.attached = false;

        tracker.posX = packet.readFloat();
        tracker.posY = packet.readFloat();
        tracker.posZ = packet.readFloat();
        tracker.motionX = packet.readFloat();
        tracker.motionY = packet.readFloat();
        tracker.motionZ = packet.readFloat();

        tracker.setPosition(tracker.posX, tracker.posY, tracker.posZ);
        tracker.setVelocity(tracker.motionX, tracker.motionY, tracker.motionZ);

        tracker.attachmentCounter = packet.readUShort();
        tracker.item = packet.readBoolean();
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:57,代碼來源:WRClientPH.java

示例7: handleSpawnMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Spawns the mob entity at the specified location, with the specified rotation, momentum and type. Updates the
 * entities Datawatchers with the entity metadata specified in the packet
 */
public void handleSpawnMob(SPacketSpawnMob packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    double d0 = packetIn.getX();
    double d1 = packetIn.getY();
    double d2 = packetIn.getZ();
    float f = (float)(packetIn.getYaw() * 360) / 256.0F;
    float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
    EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.createEntityByID(packetIn.getEntityType(), this.gameController.world);

    if (entitylivingbase != null)
    {
        EntityTracker.updateServerPosition(entitylivingbase, d0, d1, d2);
        entitylivingbase.renderYawOffset = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
        entitylivingbase.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
        Entity[] aentity = entitylivingbase.getParts();

        if (aentity != null)
        {
            int i = packetIn.getEntityID() - entitylivingbase.getEntityId();

            for (Entity entity : aentity)
            {
                entity.setEntityId(entity.getEntityId() + i);
            }
        }

        entitylivingbase.setEntityId(packetIn.getEntityID());
        entitylivingbase.setUniqueId(packetIn.getUniqueId());
        entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1);
        entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);
        entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F);
        entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F);
        this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitylivingbase);
        List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries();

        if (list != null)
        {
            entitylivingbase.getDataManager().setEntryValues(list);
        }
    }
    else
    {
        LOGGER.warn("Skipping Entity with id {}", new Object[] {Integer.valueOf(packetIn.getEntityType())});
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:51,代碼來源:NetHandlerPlayClient.java

示例8: spawnEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    if (er == null)
    {
        throw new RuntimeException( "Could not spawn mod entity ModID: " + spawnMsg.modId + " EntityID: " + spawnMsg.modEntityTypeId +
                " at ( " + spawnMsg.rawX + "," + spawnMsg.rawY + ", " + spawnMsg.rawZ + ") Please contact mod author or server admin.");
    }
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = cls.getConstructor(World.class).newInstance(wc);

            int offset = spawnMsg.entityId - entity.getEntityId();
            entity.setEntityId(spawnMsg.entityId);
            entity.setUniqueId(spawnMsg.entityUUID);
            entity.setLocationAndAngles(spawnMsg.rawX, spawnMsg.rawY, spawnMsg.rawZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.getParts();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].setEntityId(parts[j].getEntityId() + offset);
                }
            }
        }

        EntityTracker.updateServerPosition(entity, spawnMsg.rawX, spawnMsg.rawY, spawnMsg.rawZ);

        EntityPlayerSP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.getDataManager().setEntryValues(spawnMsg.dataWatcherList);
        }

        if (spawnMsg.throwerId > 0)
        {
            entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.addEntityToWorld(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity at ( " + spawnMsg.rawX + "," + spawnMsg.rawY + ", " + spawnMsg.rawZ +")");
        throw Throwables.propagate(e);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:71,代碼來源:EntitySpawnHandler.java

示例9: handleSpawnMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Spawns the mob entity at the specified location, with the specified rotation, momentum and type. Updates the
 * entities Datawatchers with the entity metadata specified in the packet
 */
public void handleSpawnMob(SPacketSpawnMob packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    double d0 = packetIn.getX();
    double d1 = packetIn.getY();
    double d2 = packetIn.getZ();
    float f = (float)(packetIn.getYaw() * 360) / 256.0F;
    float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
    EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.createEntityByID(packetIn.getEntityType(), this.gameController.theWorld);
    if (entitylivingbase == null)
    {
        net.minecraftforge.fml.common.FMLLog.info("Server attempted to spawn an unknown entity using ID: {0} at ({1}, {2}, {3}) Skipping!", packetIn.getEntityType(), d0, d1, d2);
        return;
    }
    EntityTracker.updateServerPosition(entitylivingbase, d0, d1, d2);
    entitylivingbase.renderYawOffset = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
    entitylivingbase.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
    Entity[] aentity = entitylivingbase.getParts();

    if (aentity != null)
    {
        int i = packetIn.getEntityID() - entitylivingbase.getEntityId();

        for (Entity entity : aentity)
        {
            entity.setEntityId(entity.getEntityId() + i);
        }
    }

    entitylivingbase.setEntityId(packetIn.getEntityID());
    entitylivingbase.setUniqueId(packetIn.getUniqueId());
    entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1);
    entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);
    entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F);
    entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F);
    this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitylivingbase);
    List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries();

    if (list != null)
    {
        entitylivingbase.getDataManager().setEntryValues(list);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:48,代碼來源:NetHandlerPlayClient.java


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