Java Code Examples for net.minecraft.entity.Entity#setLocationAndAngles()

The following examples show how to use net.minecraft.entity.Entity#setLocationAndAngles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchematicPlacingUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void rotateEntity(Entity entity, double x, double y, double z, Rotation rotationCombined, Mirror mirrorMain, Mirror mirrorSub)
{
    float rotationYaw = entity.rotationYaw;

    if (mirrorMain != Mirror.NONE)          { rotationYaw = entity.getMirroredYaw(mirrorMain); }
    if (mirrorSub != Mirror.NONE)           { rotationYaw = entity.getMirroredYaw(mirrorSub); }
    if (rotationCombined != Rotation.NONE)  { rotationYaw += entity.rotationYaw - entity.getRotatedYaw(rotationCombined); }

    entity.setLocationAndAngles(x, y, z, rotationYaw, entity.rotationPitch);

    entity.prevRotationYaw = rotationYaw;
    entity.prevRotationPitch = entity.rotationPitch;

    if (entity instanceof EntityLivingBase)
    {
        EntityLivingBase livingBase = (EntityLivingBase) entity;
        livingBase.rotationYawHead = rotationYaw;
        livingBase.prevRotationYawHead = rotationYaw;
        livingBase.renderYawOffset = rotationYaw;
        livingBase.prevRenderYawOffset = rotationYaw;
    }
}
 
Example 2
Source File: TileEntityWrathCageRenderer.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
public static void renderMob(WrathSpawnerLogic spawnLogic, double par1, double y, double par5, float par7) {
    Entity entity = spawnLogic.getEntityForRender();

    if (entity != null) {
        entity.setWorld(spawnLogic.getSpawnerWorld());
        float f1 = 0.4375F;
        if (spawnLogic.getEntityNameToSpawn().equals("Ghast"))
            f1 = 0.1F;
        else if (spawnLogic.getEntityNameToSpawn().equals("Slime") || spawnLogic.getEntityNameToSpawn().equals("ThaumSlime"))
            f1 = 0.4F;
        else if (spawnLogic.getEntityNameToSpawn().equals("Enderman"))
            f1 = 0.3F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        if (!spawnLogic.getSpawnerWorld().isBlockIndirectlyGettingPowered(spawnLogic.getSpawnerX(), spawnLogic.getSpawnerY(), spawnLogic.getSpawnerZ()))
            GL11.glRotatef((float) (spawnLogic.field_98284_d + (spawnLogic.field_98287_c - spawnLogic.field_98284_d) * (double) par7) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(f1, f1, f1);
        entity.setLocationAndAngles(par1, y, par5, 0.0F, 0.0F);
        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, par7);
    }
}
 
Example 3
Source File: ThermiteTeleportationHandler.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static void transferEntityToWorld(Entity ent, WorldServer oldWorld, WorldServer newWorld) {

		WorldProvider pOld = oldWorld.provider;
		WorldProvider pNew = newWorld.provider;
		double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
		double x = ent.posX * moveFactor;
		double z = ent.posZ * moveFactor;
		x = MathHelper.clamp_double(x, -29999872, 29999872);
		z = MathHelper.clamp_double(z, -29999872, 29999872);

		if (ent.isEntityAlive()) {
			ent.setLocationAndAngles(x, ent.posY, z, ent.rotationYaw, ent.rotationPitch);
			newWorld.spawnEntityInWorld(ent);
			newWorld.updateEntityWithOptionalForce(ent, false);
		}

		ent.setWorld(newWorld);
	}
 
Example 4
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Entity teleportEntityUsingTarget(Entity entity, TargetData target, boolean adjustTargetPosition, boolean allowMounts, boolean allowRiders)
{
    if (target == null || entity == null)
    {
        return null;
    }

    if (adjustTargetPosition)
    {
        target = PositionUtils.adjustTargetPosition(target, entity);
    }

    if (target.hasRotation)
    {
        entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, target.yaw, target.pitch);
    }

    return teleportEntity(entity, target.dPosX, target.dPosY, target.dPosZ, target.dimension, allowMounts, allowRiders);
}
 
Example 5
Source File: TeleporterMagicLand.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
public void placeInPortal(Entity entity, float rotationYaw) {

		int i = MathHelper.floor_double(entity.posX);
		int j = MathHelper.floor_double(entity.posY) - 1;
		int k = MathHelper.floor_double(entity.posZ);
		byte b0 = 1;
		byte b1 = 0;

		for (int l = -2; l <= 2; ++l) {
			for (int i1 = -2; i1 <= 2; ++i1) {
				for (int j1 = -1; j < 3; ++j1) {
					int k1 = i + i1 * b0 + l * b1;
					int l1 = j + j1;
					int i2 = k + i1 * b1 - l * b0;
					boolean flag = j1 < 0;
				}
			}
		}

		entity.setLocationAndAngles((double) i, ((double) j) + 2, (double) k,
				entity.rotationYaw, 0.0F);
		entity.motionX = entity.motionY = entity.motionZ = 0.0D;
		
		while (entity.worldObj.getBlockState(entity.getPosition()).getBlock().isFullCube()) {
			entity.moveEntity(0, 1, 0);
		}

	}
 
Example 6
Source File: MoCDirectTeleporter.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void placeInPortal(Entity par1Entity, double par2X, double par4Y, double par6Z, float par8)
{
	int var9 = MathHelper.floor_double(par1Entity.posX);
	int var10 = MathHelper.floor_double(par1Entity.posY) - 1;
	int var11 = MathHelper.floor_double(par1Entity.posZ);
	par1Entity.setLocationAndAngles((double) var9, (double) var10, (double) var11, par1Entity.rotationYaw, 0.0F);
	par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
}
 
Example 7
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Entity teleportEntityInsideSameDimension(Entity entity, double x, double y, double z)
{
    // Load the chunk first
    entity.getEntityWorld().getChunk((int) Math.floor(x / 16D), (int) Math.floor(z / 16D));

    entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
    entity.setPositionAndUpdate(x, y, z);
    return entity;
}
 
Example 8
Source File: TeleporterNoPortalSeekBlock.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) {
	
	double x, y, z;
	x = entityIn.posX;
	y = entityIn.posY;
	z = entityIn.posZ;
	MutableBlockPos pos = new MutableBlockPos();
	
	for(int yy = (int) y; yy < world.getHeight(); yy++) {
		pos.setPos(x, yy, z);
		if(world.isAirBlock(pos) && world.isAirBlock(pos.add(0,1,0))){
			y = yy;
			break;
		}
	}
       
    if (entityIn instanceof EntityPlayerMP)
    {
        ((EntityPlayerMP)entityIn).connection.setPlayerLocation(x,y,z, entityIn.rotationYaw, entityIn.rotationPitch);
    }
    else
    {
        entityIn.setLocationAndAngles(x,y,z, entityIn.rotationYaw, entityIn.rotationPitch);
    }
    
    return true;
}
 
Example 9
Source File: TeleporterNoPortalSeekBlock.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void teleport(Entity entity, WorldServer world) {

		if (entity.isEntityAlive()) {
			entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
			world.spawnEntity(entity);
			world.updateEntityWithOptionalForce(entity, false);
		}
		entity.setWorld(world);
	}
 
Example 10
Source File: TeleporterNoPortal.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void teleport(Entity entity, WorldServer world) {

		if (entity.isEntityAlive()) {
			entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
			world.spawnEntity(entity);
			world.updateEntityWithOptionalForce(entity, false);
		}
		entity.setWorld(world);
	}
 
Example 11
Source File: ItemEntityEgg.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public static Entity spawnEntity(World world, int id, double x, double y, double z) {
	Entity entity = ModEntityList.createEntityByID(id, world);

	if (entity != null && entity instanceof EntityLivingBase) {
		EntityLiving entityliving = (EntityLiving) entity;
		entity.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
		entityliving.rotationYawHead = entityliving.rotationYaw;
		entityliving.renderYawOffset = entityliving.rotationYaw;
		entityliving.onSpawnWithEgg((IEntityLivingData) null);
		world.spawnEntityInWorld(entity);
		entityliving.playLivingSound();
	}

	return entity;
}
 
Example 12
Source File: TeleporterPaths.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
	boolean flag = true;
	int playerX = MathHelper.floor(entityIn.posX);
	int playerZ = MathHelper.floor(entityIn.posZ);
	boolean shouldAddPortalPosition = true;
	boolean foundPortal = false;
	BlockPos object = new BlockPos(entityIn);
	long k = ChunkPos.asLong(playerX, playerZ);

	IslandMap islandMap = Core.getMapForWorld(worldServerInstance, entityIn.getPosition());
	Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096));
	//Check if we already have a portal position cached here
	if (this.destinationCoordinateCache.containsKey(k))
	{
		Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.get(k);
		object = portalposition;
		portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
		shouldAddPortalPosition = false;
	}
	else //If not then we do a simple search for the closest portal block
	{
		object = this.findPortal(new BlockPos(entityIn));
	}

	//If we found a portal location then we need to move the player to it
	if (object != null)
	{
		if (shouldAddPortalPosition)
		{
			this.destinationCoordinateCache.put(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime()));
			//this.destinationCoordinateKeys.add(Long.valueOf(k));
		}

		EnumFacing enumfacing = null;
		BlockPos pos = object;
		PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal);

		if(this.checkRoomForPlayer(pos.north()))
			pos = pos.north();
		else if(this.checkRoomForPlayer(pos.south()))
			pos = pos.south();
		else if(this.checkRoomForPlayer(pos.east()))
			pos = pos.east();
		else if(this.checkRoomForPlayer(pos.west()))
			pos = pos.west();

		entityIn.setLocationAndAngles(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, rotationYaw, entityIn.rotationPitch);
		return true;
	}
	else
	{
		return false;
	}
}
 
Example 13
Source File: ItemLivingManipulator.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private EnumActionResult releaseEntity(ItemStack containerStack, EntityPlayer player, World world,
        BlockPos pos, double x, double y, double z, EnumFacing side)
{
    ItemStack moduleStack = this.getSelectedModuleStack(containerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty())
    {
        return EnumActionResult.PASS;
    }

    NBTTagList tagList = NBTUtils.getTagList(moduleStack, WRAPPER_TAG_NAME, "Entities", Constants.NBT.TAG_COMPOUND, false);

    if (tagList == null || tagList.tagCount() == 0)
    {
        return EnumActionResult.PASS;
    }

    int current = NBTUtils.getByte(moduleStack, WRAPPER_TAG_NAME, "Current");
    int numEntities = tagList.tagCount();

    if (current >= numEntities)
    {
        current = (numEntities > 0) ? numEntities - 1 : 0;
    }

    NBTTagCompound tag = tagList.getCompoundTagAt(current);

    if (tag != null)
    {
        boolean isShulker = false;

        if (tag.getString("id").equals("minecraft:shulker") || tag.getString("id").equals("Shulker"))
        {
            // Special case to update the Shulker's attached position and position
            if (tag.hasKey("APX", Constants.NBT.TAG_INT))
            {
                int xi = pos.getX() + side.getXOffset();
                int yi = pos.getY() + side.getYOffset();
                int zi = pos.getZ() + side.getZOffset();

                tag.setTag("Pos", NBTUtils.writeDoubles(new double[] {xi + 0.5d, yi, zi + 0.5d}));
                tag.setInteger("APX", xi);
                tag.setInteger("APY", yi);
                tag.setInteger("APZ", zi);
                tag.setByte("AttachFace", (byte)side.getIndex());
                isShulker = true;
            }
        }

        Entity entity = EntityList.createEntityFromNBT(tag, world);

        if (entity == null)
        {
            return EnumActionResult.FAIL;
        }

        if (isShulker == false)
        {
            if (tag.hasKey("playerYaw", Constants.NBT.TAG_FLOAT))
            {
                float yawDiff = player.rotationYaw - tag.getFloat("playerYaw");
                entity.rotationYaw = (entity.rotationYaw + yawDiff) % 360;
            }

            PositionHelper posHelper = new PositionHelper(x, y, z);
            posHelper.adjustPositionToTouchFace(entity, side);
            entity.setLocationAndAngles(posHelper.posX, posHelper.posY, posHelper.posZ, entity.rotationYaw, entity.rotationPitch);
        }

        entity.motionY = 0.0;
        entity.fallDistance = 0.0f;
        entity.onGround = true;

        if (entity instanceof EntityLiving && this.getInstalledModuleCount(containerStack, ModuleType.TYPE_MOBPERSISTENCE) > 0)
        {
            EntityUtils.applyMobPersistence((EntityLiving)entity);
        }

        world.spawnEntity(entity);
        tagList.removeTag(current);
    }

    numEntities = tagList.tagCount();

    if (current >= numEntities)
    {
        current = (numEntities > 0) ? numEntities - 1 : 0;
    }

    NBTUtils.setByte(moduleStack, WRAPPER_TAG_NAME, "Current", (byte)current);
    this.setSelectedModuleStack(containerStack, ModuleType.TYPE_MEMORY_CARD_MISC, moduleStack);

    return EnumActionResult.SUCCESS;
}
 
Example 14
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean teleportEntityRandomly(Entity entity, double maxDist)
{
    World world = entity.getEntityWorld();

    if (canTeleportEntity(entity) == false || world.isRemote)
    {
        return false;
    }

    double deltaYaw = 0.0d;
    double deltaPitch = 0.0d;
    double x = 0.0d;
    double y = 0.0d;
    double z = 0.0d;
    maxDist = maxDist - (world.rand.nextFloat() * maxDist / 2.0d);

    // Try to find a free spot (non-colliding with blocks)
    for (int i = 0; i < 20; i++)
    {
        deltaYaw = world.rand.nextFloat() * 2d * Math.PI;
        //deltaPitch = ((90.0d - (Math.random() * 180.0d)) / 180.0d) * Math.PI; // free range on the y-direction
        deltaPitch = world.rand.nextFloat() * 0.5d * Math.PI; // only from the same level upwards
        x = entity.posX;
        y = entity.posY;
        z = entity.posZ;
        x += Math.cos(deltaPitch) * Math.cos(deltaYaw) * maxDist;
        z += Math.cos(deltaPitch) * Math.sin(deltaYaw) * maxDist;
        y += Math.sin(deltaPitch) * maxDist;

        if (entity.getEntityBoundingBox() != null && world.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty())
        {
            // Sound and particles on the original location
            addTeleportSoundsAndParticles(world, entity.posX, entity.posY, entity.posZ);

            entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

            // Sound and particles on the new, destination location.
            addTeleportSoundsAndParticles(world, x, y, z);
            return true;
        }
    }

    return false;
}
 
Example 15
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static Entity teleportEntityToDimension(Entity entity, double x, double y, double z, int dimDst)
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    WorldServer worldDst = server.getWorld(dimDst);

    teleportInProgress = true;

    if (worldDst == null || ForgeHooks.onTravelToDimension(entity, dimDst) == false)
    {
        teleportInProgress = false;
        return null;
    }

    teleportInProgress = false;

    // Load the chunk first
    int chunkX = (int) Math.floor(x / 16D);
    int chunkZ = (int) Math.floor(z / 16D);
    ChunkLoading.getInstance().loadChunkForcedWithModTicket(dimDst, chunkX, chunkZ, 10);

    if (entity instanceof EntityPlayerMP)
    {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        World worldOld = player.getEntityWorld();
        DummyTeleporter teleporter = new DummyTeleporter(worldDst);

        player.setLocationAndAngles(x, y, z, player.rotationYaw, player.rotationPitch);
        server.getPlayerList().transferPlayerToDimension(player, dimDst, teleporter);

        // Teleporting FROM The End, remove the boss bar that would otherwise get stuck on
        if (worldOld.provider instanceof WorldProviderEnd)
        {
            removeDragonBossBarHack(player, (WorldProviderEnd) worldOld.provider);
        }

        player.setPositionAndUpdate(x, y, z);
        worldDst.updateEntityWithOptionalForce(player, false);
        player.addExperienceLevel(0);
        player.setPlayerHealthUpdated();
        // TODO update food level?
    }
    else
    {
        WorldServer worldSrc = (WorldServer) entity.getEntityWorld();

        // FIXME ugly special case to prevent the chest minecart etc from duping items
        if (entity instanceof EntityMinecartContainer)
        {
            ((EntityMinecartContainer) entity).setDropItemsWhenDead(false);
        }

        Entity entityNew = EntityList.newEntity(entity.getClass(), worldDst);

        if (entityNew != null)
        {
            EntityUtils.copyDataFromOld(entityNew, entity);
            entityNew.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

            boolean flag = entityNew.forceSpawn;
            entityNew.forceSpawn = true;
            worldDst.spawnEntity(entityNew);
            entityNew.forceSpawn = flag;

            worldDst.updateEntityWithOptionalForce(entityNew, false);
            entity.isDead = true;

            worldSrc.removeEntity(entity);
            worldSrc.updateEntityWithOptionalForce(entity, false);

            worldSrc.resetUpdateEntityTick();
            worldDst.resetUpdateEntityTick();
        }

        entity = entityNew;
    }

    return entity;
}
 
Example 16
Source File: TemplateEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addEntitiesToWorld(World world, BlockPos posStart)
{
    if (this.placement.getIgnoreEntities())
    {
        return;
    }

    Mirror mirror = this.placement.getMirror();
    Rotation rotation = this.placement.getRotation();

    BlockPos posEnd = posStart.add(PositionUtils.getRelativeEndPositionFromAreaSize(this.size));
    BlockPos pos1 = PositionUtils.getMinCorner(posStart, posEnd);
    BlockPos pos2 = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1);
    List<Entity> existingEntities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(pos1, pos2));

    for (TemplateEnderUtilities.TemplateEntityInfo entityInfo : this.entities)
    {
        BlockPos pos = transformedBlockPos(this.placement, entityInfo.blockPos).add(posStart);

        NBTTagCompound nbt = entityInfo.entityData;
        UUID uuidOriginal = nbt.getUniqueId("UUID");
        Vec3d vec3d = PositionUtils.transformedVec3d(entityInfo.pos, mirror, rotation);
        Vec3d vec3d1 = vec3d.add((double)posStart.getX(), (double)posStart.getY(), (double)posStart.getZ());
        NBTTagList tagList = new NBTTagList();
        tagList.appendTag(new NBTTagDouble(vec3d1.x));
        tagList.appendTag(new NBTTagDouble(vec3d1.y));
        tagList.appendTag(new NBTTagDouble(vec3d1.z));
        nbt.setTag("Pos", tagList);
        nbt.setUniqueId("UUID", UUID.randomUUID());
        Entity entity;

        try
        {
            entity = EntityList.createEntityFromNBT(nbt, world);
        }
        catch (Exception e)
        {
            entity = null;
        }

        if (entity != null)
        {
            if (entity instanceof EntityPainting)
            {
                entity.getMirroredYaw(mirror);
                entity.getRotatedYaw(rotation);
                entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, entity.rotationYaw, entity.rotationPitch);
            }
            else
            {
                float f = entity.getMirroredYaw(mirror);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotation));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                // FIXME should call updateFacingWithBoundingBox(EnumFacing) for EntityHanging, otherwise a world reload is needed
                // for ItemFrames for example to visually update to the correct facing
            }

            // Use the original UUID if possible. If there is an entity with the same UUID within the pasted area,
            // then the old one will be killed. Otherwise if there is no entity currently in the world with
            // the same UUID, then the original UUID will be used.
            Entity existing = EntityUtils.findEntityByUUID(existingEntities, uuidOriginal);
            if (existing != null)
            {
                world.removeEntityDangerously(existing);
                entity.setUniqueId(uuidOriginal);
            }
            else if (world instanceof WorldServer && ((WorldServer) world).getEntityFromUuid(uuidOriginal) == null)
            {
                entity.setUniqueId(uuidOriginal);
            }

            world.spawnEntity(entity);
        }
    }
}
 
Example 17
Source File: ThermiteTeleporter.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean placeInExistingPortal(Entity e, double x, double y, double z, float rY)
{
    e.setLocationAndAngles(x, y, z, rY, e.rotationPitch);
    return true;
}
 
Example 18
Source File: WrathSpawnerLogic.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public void updateSpawner() {
    if (!mobSet)
        return;

    double d0;

    if (this.getSpawnerWorld().isRemote && (fuel > 0 || Config.wrathCost <= 0)) {
        double d1 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat());
        double d2 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat());
        d0 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat());
        // this.getSpawnerWorld().spawnParticle("smoke", d1, d2, d0, 0.0D,
        // 0.0D, 0.0D);
        // this.getSpawnerWorld().spawnParticle("flame", d1, d2, d0, 0.0D,
        // 0.0D, 0.0D);
        Thaumcraft.proxy.sparkle((float) d1, (float) d2, (float) d0, 0x870404);

        if (this.spawnDelay > 0) {
            --this.spawnDelay;
        }

        this.field_98284_d = this.field_98287_c;
        this.field_98287_c = (this.field_98287_c + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D;
    } else if (Config.wrathCage) {
        if (Config.wrathCost > 0 && fuel <= 0) {
            if (mobSpawnerEntity.special >= Config.wrathCost) {
                mobSpawnerEntity.special -= Config.wrathCost;
                slothful = false;
                fuel = Config.wrathEff;
                mobSpawnerEntity.getWorldObj().markBlockForUpdate(getSpawnerX(), getSpawnerY(), getSpawnerZ());
            } else if (mobSpawnerEntity.wrath >= Config.wrathCost) {
                mobSpawnerEntity.wrath -= Config.wrathCost;
                slothful = false;
                fuel = Config.wrathEff;
                mobSpawnerEntity.getWorldObj().markBlockForUpdate(getSpawnerX(), getSpawnerY(), getSpawnerZ());
            } else if (mobSpawnerEntity.sloth >= Config.wrathCost) {
                mobSpawnerEntity.sloth -= Config.wrathCost;
                slothful = true;
                fuel = Config.wrathEff;
                mobSpawnerEntity.getWorldObj().markBlockForUpdate(getSpawnerX(), getSpawnerY(), getSpawnerZ());
            }
        }

        if (this.spawnDelay == -1) {
            this.updateDelay();
        }

        if (fuel <= 0 && Config.wrathCost > 0)
            return;

        if (this.spawnDelay > 0) {
            --this.spawnDelay;
            return;
        }

        for (int i = 0; i < this.spawnCount && (fuel > 0 || Config.wrathCost <= 0); ++i) {
            Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld());

            if (entity == null) {
                return;
            }

            //int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getAABBPool().getAABB((double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)).expand((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size();
            int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox((double)this.getSpawnerX(), (double)this.getSpawnerY(), (double)this.getSpawnerZ(), (double)(this.getSpawnerX() + 1), (double)(this.getSpawnerY() + 1), (double)(this.getSpawnerZ() + 1)).expand((double)(this.spawnRange * 2), 4.0D, (double)(this.spawnRange * 2))).size();

            if (j >= this.maxNearbyEntities) {
                this.updateDelay();
                return;
            }

            d0 = (double) this.getSpawnerX() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange;
            double d3 = (double) (this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1);
            double d4 = (double) this.getSpawnerZ() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange;
            EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null;
            entity.setLocationAndAngles(d0, d3, d4, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);

            if (
            // entityliving == null ||
            entityCanSpawn(entityliving))
            // entityliving.getCanSpawnHere())
            {
                this.spawnMob(entity);
                this.getSpawnerWorld().playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0);

                if (entityliving != null) {
                    entityliving.spawnExplosionParticle();
                    fuel--;
                }

                this.updateDelay();
            } else if (entityliving != null)
                entityliving.isDead = true;
        }

    }
}
 
Example 19
Source File: BlockDrawingHelper.java    From malmo with MIT License 4 votes vote down vote up
protected void positionEntity( Entity entity, double x, double y, double z, float yaw, float pitch )
{
    entity.setLocationAndAngles(x, y, z, yaw, pitch);
}