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


Java IEntityAdditionalSpawnData类代码示例

本文整理汇总了Java中cpw.mods.fml.common.registry.IEntityAdditionalSpawnData的典型用法代码示例。如果您正苦于以下问题:Java IEntityAdditionalSpawnData类的具体用法?Java IEntityAdditionalSpawnData怎么用?Java IEntityAdditionalSpawnData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IEntityAdditionalSpawnData类属于cpw.mods.fml.common.registry包,在下文中一共展示了IEntityAdditionalSpawnData类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTileInfoPacket

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
public static Packet131MapData getTileInfoPacket(TileEntity tile) {
	if (!(tile instanceof IEntityAdditionalSpawnData)) throw new IllegalArgumentException("Tile information packets require a TileEntity implementing IEntityAdditionalSpawnData");
	IEntityAdditionalSpawnData data = (IEntityAdditionalSpawnData)tile;
	
	ByteArrayDataOutput os = ByteStreams.newDataOutput();
	os.writeInt(tile.xCoord);
	os.writeInt(tile.yCoord);
	os.writeInt(tile.zCoord);
	data.writeSpawnData(os);
	
	return PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)3, os.toByteArray());
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:13,代码来源:NetworkHelper.java

示例2: toBytes

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
void toBytes(ByteBuf buf)
{
    super.toBytes(buf);
    ByteBufUtils.writeUTF8String(buf, modId);
    buf.writeInt(modEntityTypeId);
    // posX, posY, posZ
    buf.writeInt(MathHelper.func_76128_c(entity.field_70165_t * 32D));
    buf.writeInt(MathHelper.func_76128_c(entity.field_70163_u * 32D));
    buf.writeInt(MathHelper.func_76128_c(entity.field_70161_v * 32D));
    // yaw, pitch
    buf.writeByte((byte)(entity.field_70177_z * 256.0F / 360.0F));
    buf.writeByte((byte) (entity.field_70125_A * 256.0F / 360.0F));
    // head yaw
    if (entity instanceof EntityLivingBase)
    {
        buf.writeByte((byte) (((EntityLivingBase)entity).field_70759_as * 256.0F / 360.0F));
    }
    else
    {
        buf.writeByte(0);
    }
    ByteBuf tmpBuf = Unpooled.buffer();
    PacketBuffer pb = new PacketBuffer(tmpBuf);
    try
    {
        entity.func_70096_w().func_151509_a(pb);
    } catch (IOException e)
    {
        FMLLog.log(Level.FATAL,e,"Encountered fatal exception trying to send entity spawn data watchers");
        throw Throwables.propagate(e);
    }
    buf.writeBytes(tmpBuf);

    if (entity instanceof IThrowableEntity)
    {
        Entity owner = ((IThrowableEntity)entity).getThrower();
        buf.writeInt(owner == null ? entity.func_145782_y() : owner.func_145782_y());
        double maxVel = 3.9D;
        double mX = entity.field_70159_w;
        double mY = entity.field_70181_x;
        double mZ = entity.field_70179_y;
        if (mX < -maxVel) mX = -maxVel;
        if (mY < -maxVel) mY = -maxVel;
        if (mZ < -maxVel) mZ = -maxVel;
        if (mX >  maxVel) mX =  maxVel;
        if (mY >  maxVel) mY =  maxVel;
        if (mZ >  maxVel) mZ =  maxVel;
        buf.writeInt((int)(mX * 8000D));
        buf.writeInt((int)(mY * 8000D));
        buf.writeInt((int)(mZ * 8000D));
    }
    else
    {
        buf.writeInt(0);
    }
    if (entity instanceof IEntityAdditionalSpawnData)
    {
        tmpBuf = Unpooled.buffer();
        ((IEntityAdditionalSpawnData)entity).writeSpawnData(tmpBuf);
        buf.writeBytes(tmpBuf);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:64,代码来源:FMLMessage.java

示例3: spawnEntity

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的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.scaledX + "," + spawnMsg.scaledY + ", " + spawnMsg.scaledZ + ") 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 = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.func_145782_y();
            entity.func_145769_d(spawnMsg.entityId);
            entity.func_70012_b(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving) entity).field_70759_as = spawnMsg.scaledHeadYaw;
            }

            Entity parts[] = entity.func_70021_al();
            if (parts != null)
            {
                for (int j = 0; j < parts.length; j++)
                {
                    parts[j].func_145769_d(parts[j].func_145782_y() + offset);
                }
            }
        }

        entity.field_70118_ct = spawnMsg.rawX;
        entity.field_70117_cu = spawnMsg.rawY;
        entity.field_70116_cv = spawnMsg.rawZ;

        EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = clientPlayer.func_145782_y() == spawnMsg.throwerId ? clientPlayer : wc.func_73045_a(spawnMsg.throwerId);
            ((IThrowableEntity) entity).setThrower(thrower);
        }

        if (spawnMsg.dataWatcherList != null)
        {
            entity.func_70096_w().func_75687_a((List<?>) spawnMsg.dataWatcherList);
        }

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

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
        }
        wc.func_73027_a(spawnMsg.entityId, entity);
    } catch (Exception e)
    {
        FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity at ( " + spawnMsg.scaledX + "," + spawnMsg.scaledY + ", " + spawnMsg.scaledZ +")");
        throw Throwables.propagate(e);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:72,代码来源:EntitySpawnHandler.java

示例4: toBytes

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
void toBytes(ByteBuf buf)
{
    super.toBytes(buf);
    ByteBufUtils.writeUTF8String(buf, modId);
    buf.writeInt(modEntityTypeId);
    // posX, posY, posZ
    buf.writeInt(MathHelper.floor_double(entity.posX * 32D));
    buf.writeInt(MathHelper.floor_double(entity.posY * 32D));
    buf.writeInt(MathHelper.floor_double(entity.posZ * 32D));
    // yaw, pitch
    buf.writeByte((byte)(entity.rotationYaw * 256.0F / 360.0F));
    buf.writeByte((byte) (entity.rotationPitch * 256.0F / 360.0F));
    // head yaw
    if (entity instanceof EntityLivingBase)
    {
        buf.writeByte((byte) (((EntityLivingBase)entity).rotationYawHead * 256.0F / 360.0F));
    }

    ByteBuf tmpBuf = Unpooled.buffer();
    PacketBuffer pb = new PacketBuffer(tmpBuf);
    try
    {
        entity.getDataWatcher().func_151509_a(pb);
    } catch (IOException e)
    {
        // Sigh
    }
    buf.writeBytes(tmpBuf);

    if (entity instanceof IThrowableEntity)
    {
        Entity owner = ((IThrowableEntity)entity).getThrower();
        buf.writeInt(owner == null ? entity.getEntityId() : owner.getEntityId());
        double maxVel = 3.9D;
        double mX = entity.motionX;
        double mY = entity.motionY;
        double mZ = entity.motionZ;
        if (mX < -maxVel) mX = -maxVel;
        if (mY < -maxVel) mY = -maxVel;
        if (mZ < -maxVel) mZ = -maxVel;
        if (mX >  maxVel) mX =  maxVel;
        if (mY >  maxVel) mY =  maxVel;
        if (mZ >  maxVel) mZ =  maxVel;
        buf.writeInt((int)(mX * 8000D));
        buf.writeInt((int)(mY * 8000D));
        buf.writeInt((int)(mZ * 8000D));
    }
    else
    {
        buf.writeInt(0);
    }
    if (entity instanceof IEntityAdditionalSpawnData)
    {
        tmpBuf = Unpooled.buffer();
        ((IEntityAdditionalSpawnData)entity).writeSpawnData(tmpBuf);
        buf.writeBytes(tmpBuf);
    }
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:60,代码来源:FMLMessage.java

示例5: spawnEntity

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(spawnMsg);
        } else
        {
            entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

            int offset = spawnMsg.entityId - entity.getEntityId();
            entity.setEntityId(spawnMsg.entityId);
            entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, 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);
                }
            }
        }

        entity.serverPosX = spawnMsg.rawX;
        entity.serverPosY = spawnMsg.rawY;
        entity.serverPosZ = spawnMsg.rawZ;

        EntityClientPlayerMP 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.getDataWatcher().updateWatchedObjectsFromList((List<?>) 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");
        throw Throwables.propagate(e);
    }
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:67,代码来源:EntitySpawnHandler.java

示例6: spawnEntityIntoClientWorld

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet)
{
    WorldClient wc = client.field_71441_e;

    Class<? extends Entity> cls = er.getEntityClass();

    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(packet);
        }
        else
        {
            entity = (Entity)(cls.getConstructor(World.class).newInstance(wc));
            int offset = packet.entityId - entity.field_70157_k;
            entity.field_70157_k = packet.entityId;
            entity.func_70012_b(packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving)entity).field_70759_as = packet.scaledHeadYaw;
            }

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

        entity.field_70118_ct = packet.rawX;
        entity.field_70117_cu = packet.rawY;
        entity.field_70116_cv = packet.rawZ;

        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = client.field_71439_g.field_70157_k == packet.throwerId ? client.field_71439_g : wc.func_73045_a(packet.throwerId);
            ((IThrowableEntity)entity).setThrower(thrower);
        }

        if (packet.metadata != null)
        {
            entity.func_70096_w().func_75687_a((List)packet.metadata);
        }

        if (packet.throwerId > 0)
        {
            entity.func_70016_h(packet.speedScaledX, packet.speedScaledY, packet.speedScaledZ);
        }

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData)entity).readSpawnData(packet.dataStream);
        }

        wc.func_73027_a(packet.entityId, entity);
        return entity;
    }
    catch (Exception e)
    {
        FMLLog.log(Level.SEVERE, e, "A severe problem occurred during the spawning of an entity");
        throw Throwables.propagate(e);
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:70,代码来源:FMLClientHandler.java

示例7: generatePacket

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
public byte[] generatePacket(Object... data)
{
    EntityRegistration er = (EntityRegistration) data[0];
    Entity ent = (Entity) data[1];
    NetworkModHandler handler = (NetworkModHandler) data[2];
    ByteArrayDataOutput dat = ByteStreams.newDataOutput();

    dat.writeInt(handler.getNetworkId());
    dat.writeInt(er.getModEntityId());
    // entity id
    dat.writeInt(ent.field_70157_k);

    // entity pos x,y,z
    dat.writeInt(MathHelper.func_76128_c(ent.field_70165_t * 32D));
    dat.writeInt(MathHelper.func_76128_c(ent.field_70163_u * 32D));
    dat.writeInt(MathHelper.func_76128_c(ent.field_70161_v * 32D));

    // yaw, pitch
    dat.writeByte((byte) (ent.field_70177_z * 256.0F / 360.0F));
    dat.writeByte((byte) (ent.field_70125_A * 256.0F / 360.0F));

    // head yaw
    if (ent instanceof EntityLiving)
    {
        dat.writeByte((byte) (((EntityLiving)ent).field_70759_as * 256.0F / 360.0F));
    }
    else
    {
        dat.writeByte(0);
    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    try
    {
        ent.func_70096_w().func_75689_a(dos);
    }
    catch (IOException e)
    {
        // unpossible
    }

    dat.write(bos.toByteArray());

    if (ent instanceof IThrowableEntity)
    {
        Entity owner = ((IThrowableEntity)ent).getThrower();
        dat.writeInt(owner == null ? ent.field_70157_k : owner.field_70157_k);
        double maxVel = 3.9D;
        double mX = ent.field_70159_w;
        double mY = ent.field_70181_x;
        double mZ = ent.field_70179_y;
        if (mX < -maxVel) mX = -maxVel;
        if (mY < -maxVel) mY = -maxVel;
        if (mZ < -maxVel) mZ = -maxVel;
        if (mX >  maxVel) mX =  maxVel;
        if (mY >  maxVel) mY =  maxVel;
        if (mZ >  maxVel) mZ =  maxVel;
        dat.writeInt((int)(mX * 8000D));
        dat.writeInt((int)(mY * 8000D));
        dat.writeInt((int)(mZ * 8000D));
    }
    else
    {
        dat.writeInt(0);
    }
    if (ent instanceof IEntityAdditionalSpawnData)
    {
        ((IEntityAdditionalSpawnData)ent).writeSpawnData(dat);
    }

    return dat.toByteArray();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:74,代码来源:EntitySpawnPacket.java

示例8: spawnEntityIntoClientWorld

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet)
{
    WorldClient wc = client.theWorld;

    Class<? extends Entity> cls = er.getEntityClass();

    try
    {
        Entity entity;
        if (er.hasCustomSpawning())
        {
            entity = er.doCustomSpawning(packet);
        }
        else
        {
            entity = (Entity)(cls.getConstructor(World.class).newInstance(wc));
            int offset = packet.entityId - entity.entityId;
            entity.entityId = packet.entityId;
            entity.setLocationAndAngles(packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch);
            if (entity instanceof EntityLiving)
            {
                ((EntityLiving)entity).rotationYawHead = packet.scaledHeadYaw;
            }

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

        entity.serverPosX = packet.rawX;
        entity.serverPosY = packet.rawY;
        entity.serverPosZ = packet.rawZ;

        if (entity instanceof IThrowableEntity)
        {
            Entity thrower = client.thePlayer.entityId == packet.throwerId ? client.thePlayer : wc.getEntityByID(packet.throwerId);
            ((IThrowableEntity)entity).setThrower(thrower);
        }

        if (packet.metadata != null)
        {
            entity.getDataWatcher().updateWatchedObjectsFromList((List)packet.metadata);
        }

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

        if (entity instanceof IEntityAdditionalSpawnData)
        {
            ((IEntityAdditionalSpawnData)entity).readSpawnData(packet.dataStream);
        }

        wc.addEntityToWorld(packet.entityId, entity);
        return entity;
    }
    catch (Exception e)
    {
        FMLLog.log(Level.SEVERE, e, "A severe problem occurred during the spawning of an entity");
        throw Throwables.propagate(e);
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:70,代码来源:FMLClientHandler.java

示例9: generatePacket

import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; //导入依赖的package包/类
@Override
public byte[] generatePacket(Object... data)
{
    EntityRegistration er = (EntityRegistration) data[0];
    Entity ent = (Entity) data[1];
    NetworkModHandler handler = (NetworkModHandler) data[2];
    ByteArrayDataOutput dat = ByteStreams.newDataOutput();

    dat.writeInt(handler.getNetworkId());
    dat.writeInt(er.getModEntityId());
    // entity id
    dat.writeInt(ent.entityId);

    // entity pos x,y,z
    dat.writeInt(MathHelper.floor_double(ent.posX * 32D));
    dat.writeInt(MathHelper.floor_double(ent.posY * 32D));
    dat.writeInt(MathHelper.floor_double(ent.posZ * 32D));

    // yaw, pitch
    dat.writeByte((byte) (ent.rotationYaw * 256.0F / 360.0F));
    dat.writeByte((byte) (ent.rotationPitch * 256.0F / 360.0F));

    // head yaw
    if (ent instanceof EntityLiving)
    {
        dat.writeByte((byte) (((EntityLiving)ent).rotationYawHead * 256.0F / 360.0F));
    }
    else
    {
        dat.writeByte(0);
    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    try
    {
        ent.getDataWatcher().writeWatchableObjects(dos);
    }
    catch (IOException e)
    {
        // unpossible
    }

    dat.write(bos.toByteArray());

    if (ent instanceof IThrowableEntity)
    {
        Entity owner = ((IThrowableEntity)ent).getThrower();
        dat.writeInt(owner == null ? ent.entityId : owner.entityId);
        double maxVel = 3.9D;
        double mX = ent.motionX;
        double mY = ent.motionY;
        double mZ = ent.motionZ;
        if (mX < -maxVel) mX = -maxVel;
        if (mY < -maxVel) mY = -maxVel;
        if (mZ < -maxVel) mZ = -maxVel;
        if (mX >  maxVel) mX =  maxVel;
        if (mY >  maxVel) mY =  maxVel;
        if (mZ >  maxVel) mZ =  maxVel;
        dat.writeInt((int)(mX * 8000D));
        dat.writeInt((int)(mY * 8000D));
        dat.writeInt((int)(mZ * 8000D));
    }
    else
    {
        dat.writeInt(0);
    }
    if (ent instanceof IEntityAdditionalSpawnData)
    {
        ((IEntityAdditionalSpawnData)ent).writeSpawnData(dat);
    }

    return dat.toByteArray();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:74,代码来源:EntitySpawnPacket.java


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