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


Java Entity.setVelocity方法代碼示例

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


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

示例1: handleEntityVelocity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(S12PacketEntityVelocity packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

	if (Minecraft.getMinecraft().thePlayer == entity) {
		EventPlayerVelocity eventPlayerVelocity = new EventPlayerVelocity(100, 100);
		eventPlayerVelocity.call();
		if (eventPlayerVelocity.isCancelled()) {
			return;
		}
	} else if (entity != null) {
		entity.setVelocity((packetIn.getMotionX() * 100 / 100) / 8000.0D,
				(packetIn.getMotionY() * 100 / 100) / 8000.0D, (packetIn.getMotionZ() * 100 / 100) / 8000.0D);

	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:NetHandlerPlayClient.java

示例2: DrawPrimitive

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/** Spawn a single entity at the specified position.
 * @param e the actual entity to be spawned.
 * @param w the world in which to spawn the entity.
 * @throws Exception
 */
private void DrawPrimitive( DrawEntity e, World w ) throws Exception
{
    String entityName = e.getType().getValue();
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", entityName);
    Entity entity;
    try
    {
        entity = EntityList.createEntityFromNBT(nbttagcompound, w);
        if (entity != null)
        {
            positionEntity(entity, e.getX().doubleValue(), e.getY().doubleValue(), e.getZ().doubleValue(), e.getYaw().floatValue(), e.getPitch().floatValue());
            entity.setVelocity(e.getXVel().doubleValue(), e.getYVel().doubleValue(), e.getZVel().doubleValue());
            w.spawnEntityInWorld(entity);
        }
    }
    catch (RuntimeException runtimeexception)
    {
        // Cannot summon this entity.
        throw new Exception("Couldn't create entity type: " + e.getType().getValue());
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:28,代碼來源:BlockDrawingHelper.java

示例3: handleEntityVelocity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    if(Hacks.findMod(AntiVelocity.class).isEnabled())
	{
		return;
	}
    
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:19,代碼來源:NetHandlerPlayClient.java

示例4: handleEntityVelocity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(S12PacketEntityVelocity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:14,代碼來源:NetHandlerPlayClient.java

示例5: handleEntityVelocity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:14,代碼來源:NetHandlerPlayClient.java

示例6: setMotion

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public static void setMotion(Entity ent, double x, double y, double z) {
    ent.setVelocity(x,y,z);
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:4,代碼來源:ZWrapper.java

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


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