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


Java WorldClient.addEntityToWorld方法代码示例

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


在下文中一共展示了WorldClient.addEntityToWorld方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: throwTracker

import net.minecraft.client.multiplayer.WorldClient; //导入方法依赖的package包/类
private void throwTracker(WorldClient world, EntityPlayer player, int entityID, int throwerID, int freq) {
    Entity thrower = world.getEntityByID(throwerID);
    if (throwerID == player.getEntityId())
        thrower = player;

    if (thrower != null && thrower instanceof EntityLiving) {
        EntityWirelessTracker tracker = new EntityWirelessTracker(world, 0, (EntityLiving) thrower);
        tracker.setEntityId(entityID);
        world.addEntityToWorld(entityID, tracker);
        world.playSound(null, thrower.posX, thrower.posY, thrower.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
    }
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:13,代码来源:WRClientPH.java

示例2: throwREP

import net.minecraft.client.multiplayer.WorldClient; //导入方法依赖的package包/类
private void throwREP(int entityID, int throwerID, WorldClient world, EntityPlayer player) {
    Entity thrower = world.getEntityByID(throwerID);
    if (throwerID == player.getEntityId())
        thrower = player;

    if (thrower != null && thrower instanceof EntityLivingBase) {
        EntityREP rep = new EntityREP(world, (EntityLivingBase) thrower);
        rep.setEntityId(entityID);
        world.addEntityToWorld(entityID, rep);
    }
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:12,代码来源:WRClientPH.java

示例3: processTrackerUpdate

import net.minecraft.client.multiplayer.WorldClient; //导入方法依赖的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

示例4: spawnEntity

import net.minecraft.client.multiplayer.WorldClient; //导入方法依赖的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


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