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

The following examples show how to use net.minecraft.entity.Entity#setWorld() . 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: 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 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: 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 4
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 5
Source File: GuiEntityRender.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	int w = getWidth();
	int h = getHeight();
	
	enableBlendAlphaStuffs();
	setRenderColorARGB(_colorBackground); drawRect(1, 1, w - 2, h - 2);
	setRenderColorARGB(_colorBorder);     drawOutline(0, 0, w, h);
	disableBlendAlphaStuffs();
	
	Entity entity = getEntity();
	if (entity == null) return;
	
	AxisAlignedBB bbox = entity.getRenderBoundingBox();
	float entityWidth  = (float)(bbox.maxX - bbox.minX);
	float entityHeight = (float)(bbox.maxY - bbox.minY);
	float scale = Math.min((w - RESERVED_SPACE) / entityWidth,
	                       (h - RESERVED_SPACE) / entityHeight) * _zoom;
	float yaw   = _yawDefault + _yaw;
	float pitch = _pitchDefault + _pitch;
	
	getContext().pushScissor(this, 1, 1, w - 2, h - 2);
	
	if (entity.getEntityWorld() == null)
		entity.setWorld(DummyWorld.INSTANCE);
	if (getMC().player == null) {
		World world = entity.getEntityWorld();
		if (!(world instanceof DummyWorld)) return;
		getMC().player = ((DummyWorld)world).player;
		getMC().player.setWorld(world);
	}
	
	setRenderColorARGB(Color.WHITE);
	GlStateManager.enableDepth();
	// From GuiInventory.drawEntityOnScreen
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(w * _centerX, h * _centerY, 100.0F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0.0F, -(entityHeight / 2), 0.0F);
	GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
	
	RenderHelper.enableStandardItemLighting();
	
	RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
	rendermanager.setPlayerViewY(180.0F);
	rendermanager.setRenderShadow(false);
	rendermanager.renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	rendermanager.setRenderShadow(true);
	
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
	
	GlStateManager.disableDepth();
	if (getMC().player instanceof DummyPlayerSP)
		getMC().player = null;
	getContext().popScissor();
}