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


Java Entity.setPositionAndRotation方法代碼示例

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


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

示例1: onHitEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@SubscribeEvent
public void onHitEntity(LivingHurtEvent event) {
	
	if (event.getAmount() <= 0 || event.getEntityLiving() instanceof EntityPlayer) return;
	
	if (!(event.getSource().getSourceOfDamage() instanceof EntityPlayer)) return;
	
	ItemStack transformer = BaublesApi.getBaublesHandler((EntityPlayer)event.getSource().getSourceOfDamage()).getStackInSlot(6);
	if (transformer == null || (transformer != null && transformer.getItem() != this)) return;
	
	Random rand = new Random();
	if (rand.nextInt(100) != 0) return;
	
	EntityLivingBase elb = event.getEntityLiving();
	List<String> entities = new ArrayList<String>(EntityList.ENTITY_EGGS.keySet());
	String randomString = entities.get(rand.nextInt(entities.size()));
	Entity entity = EntityList.createEntityByName(randomString, elb.worldObj);
	if (!entity.isNonBoss()) return;
	entity.setPositionAndRotation(elb.posX, elb.posY, elb.posZ, elb.rotationYaw, elb.rotationPitch);
	
	elb.worldObj.spawnEntityInWorld(entity);
	elb.setDead();
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:24,代碼來源:EmblemTransformation.java

示例2: onItemUse

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.getEntityWorld().isRemote) return EnumActionResult.FAIL;
    if (!containsEntity(stack)) return EnumActionResult.FAIL;
    Entity entity = getEntityFromStack(stack, worldIn, true);
    BlockPos blockPos = pos.offset(facing);
    entity.setPositionAndRotation(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, 0, 0);
    stack.setTagCompound(new NBTTagCompound());
    player.setHeldItem(hand, stack);
    worldIn.spawnEntity(entity);
    if (entity instanceof EntityLiving) ((EntityLiving) entity).playLivingSound();
    return EnumActionResult.SUCCESS;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:15,代碼來源:MobImprisonmentToolItem.java

示例3: handleMoveVehicle

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public void handleMoveVehicle(SPacketMoveVehicle packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.gameController.player.getLowestRidingEntity();

    if (entity != this.gameController.player && entity.canPassengerSteer())
    {
        entity.setPositionAndRotation(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getYaw(), packetIn.getPitch());
        this.netManager.sendPacket(new CPacketVehicleMove(entity));
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:12,代碼來源:NetHandlerPlayClient.java

示例4: canMountEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting)
{
    boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.worldObj, isMounting));

    if(isCanceled)
    {
        entityMounting.setPositionAndRotation(entityMounting.posX, entityMounting.posY, entityMounting.posZ, entityMounting.prevRotationYaw, entityMounting.prevRotationPitch);
        return false;
    }
    else
        return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:13,代碼來源:ForgeEventFactory.java

示例5: handleMoveVehicle

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public void handleMoveVehicle(SPacketMoveVehicle packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.gameController.thePlayer.getLowestRidingEntity();

    if (entity != this.gameController.thePlayer && entity.canPassengerSteer())
    {
        entity.setPositionAndRotation(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getYaw(), packetIn.getPitch());
        this.netManager.sendPacket(new CPacketVehicleMove(entity));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:12,代碼來源:NetHandlerPlayClient.java

示例6: processVehicleMove

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public void processVehicleMove(CPacketVehicleMove packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (isMoveVehiclePacketInvalid(packetIn))
    {
        this.kickPlayerFromServer("Invalid move vehicle packet received");
    }
    else
    {
        Entity entity = this.playerEntity.getLowestRidingEntity();

        if (entity != this.playerEntity && entity.getControllingPassenger() == this.playerEntity && entity == this.lowestRiddenEnt)
        {
            WorldServer worldserver = this.playerEntity.getServerWorld();
            double d0 = entity.posX;
            double d1 = entity.posY;
            double d2 = entity.posZ;
            double d3 = packetIn.getX();
            double d4 = packetIn.getY();
            double d5 = packetIn.getZ();
            float f = packetIn.getYaw();
            float f1 = packetIn.getPitch();
            double d6 = d3 - this.lowestRiddenX;
            double d7 = d4 - this.lowestRiddenY;
            double d8 = d5 - this.lowestRiddenZ;
            double d9 = entity.motionX * entity.motionX + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ;
            double d10 = d6 * d6 + d7 * d7 + d8 * d8;

            if (d10 - d9 > 100.0D && (!this.serverController.isSinglePlayer() || !this.serverController.getServerOwner().equals(entity.getName())))
            {
                LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] {entity.getName(), this.playerEntity.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)});
                this.netManager.sendPacket(new SPacketMoveVehicle(entity));
                return;
            }

            boolean flag = worldserver.getCollisionBoxes(entity, entity.getEntityBoundingBox().contract(0.0625D)).isEmpty();
            d6 = d3 - this.lowestRiddenX1;
            d7 = d4 - this.lowestRiddenY1 - 1.0E-6D;
            d8 = d5 - this.lowestRiddenZ1;
            entity.moveEntity(MoverType.PLAYER, d6, d7, d8);
            double d11 = d7;
            d6 = d3 - entity.posX;
            d7 = d4 - entity.posY;

            if (d7 > -0.5D || d7 < 0.5D)
            {
                d7 = 0.0D;
            }

            d8 = d5 - entity.posZ;
            d10 = d6 * d6 + d7 * d7 + d8 * d8;
            boolean flag1 = false;

            if (d10 > 0.0625D)
            {
                flag1 = true;
                LOGGER.warn("{} moved wrongly!", new Object[] {entity.getName()});
            }

            entity.setPositionAndRotation(d3, d4, d5, f, f1);
            boolean flag2 = worldserver.getCollisionBoxes(entity, entity.getEntityBoundingBox().contract(0.0625D)).isEmpty();

            if (flag && (flag1 || !flag2))
            {
                entity.setPositionAndRotation(d0, d1, d2, f, f1);
                this.netManager.sendPacket(new SPacketMoveVehicle(entity));
                return;
            }

            this.serverController.getPlayerList().serverUpdateMovingPlayer(this.playerEntity);
            this.playerEntity.addMovementStat(this.playerEntity.posX - d0, this.playerEntity.posY - d1, this.playerEntity.posZ - d2);
            this.vehicleFloating = d11 >= -0.03125D && !this.serverController.isFlightAllowed() && !worldserver.checkBlockCollision(entity.getEntityBoundingBox().expandXyz(0.0625D).addCoord(0.0D, -0.55D, 0.0D));
            this.lowestRiddenX1 = entity.posX;
            this.lowestRiddenY1 = entity.posY;
            this.lowestRiddenZ1 = entity.posZ;
        }
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:80,代碼來源:NetHandlerPlayServer.java

示例7: processVehicleMove

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public void processVehicleMove(CPacketVehicleMove packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (isMoveVehiclePacketInvalid(packetIn))
    {
        this.kickPlayerFromServer("Invalid move vehicle packet received");
    }
    else
    {
        Entity entity = this.playerEntity.getLowestRidingEntity();

        if (entity != this.playerEntity && entity.getControllingPassenger() == this.playerEntity && entity == this.lowestRiddenEnt)
        {
            WorldServer worldserver = this.playerEntity.getServerWorld();
            double d0 = entity.posX;
            double d1 = entity.posY;
            double d2 = entity.posZ;
            double d3 = packetIn.getX();
            double d4 = packetIn.getY();
            double d5 = packetIn.getZ();
            float f = packetIn.getYaw();
            float f1 = packetIn.getPitch();
            double d6 = d3 - this.lowestRiddenX;
            double d7 = d4 - this.lowestRiddenY;
            double d8 = d5 - this.lowestRiddenZ;
            double d9 = entity.motionX * entity.motionX + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ;
            double d10 = d6 * d6 + d7 * d7 + d8 * d8;

            if (d10 - d9 > 100.0D && (!this.serverController.isSinglePlayer() || !this.serverController.getServerOwner().equals(entity.getName())))
            {
                LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] {entity.getName(), this.playerEntity.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)});
                this.netManager.sendPacket(new SPacketMoveVehicle(entity));
                return;
            }

            boolean flag = worldserver.getCollisionBoxes(entity, entity.getEntityBoundingBox().contract(0.0625D)).isEmpty();
            d6 = d3 - this.lowestRiddenX1;
            d7 = d4 - this.lowestRiddenY1 - 1.0E-6D;
            d8 = d5 - this.lowestRiddenZ1;
            entity.moveEntity(d6, d7, d8);
            double d11 = d7;
            d6 = d3 - entity.posX;
            d7 = d4 - entity.posY;

            if (d7 > -0.5D || d7 < 0.5D)
            {
                d7 = 0.0D;
            }

            d8 = d5 - entity.posZ;
            d10 = d6 * d6 + d7 * d7 + d8 * d8;
            boolean flag1 = false;

            if (d10 > 0.0625D)
            {
                flag1 = true;
                LOGGER.warn("{} moved wrongly!", new Object[] {entity.getName()});
            }

            entity.setPositionAndRotation(d3, d4, d5, f, f1);
            boolean flag2 = worldserver.getCollisionBoxes(entity, entity.getEntityBoundingBox().contract(0.0625D)).isEmpty();

            if (flag && (flag1 || !flag2))
            {
                entity.setPositionAndRotation(d0, d1, d2, f, f1);
                this.netManager.sendPacket(new SPacketMoveVehicle(entity));
                return;
            }

            this.serverController.getPlayerList().serverUpdateMountedMovingPlayer(this.playerEntity);
            this.playerEntity.addMovementStat(this.playerEntity.posX - d0, this.playerEntity.posY - d1, this.playerEntity.posZ - d2);
            this.vehicleFloating = d11 >= -0.03125D && !this.serverController.isFlightAllowed() && !worldserver.checkBlockCollision(entity.getEntityBoundingBox().expandXyz(0.0625D).addCoord(0.0D, -0.55D, 0.0D));
            this.lowestRiddenX1 = entity.posX;
            this.lowestRiddenY1 = entity.posY;
            this.lowestRiddenZ1 = entity.posZ;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:80,代碼來源:NetHandlerPlayServer.java


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