Java Code Examples for net.minecraft.tileentity.TileEntity#getWorld()
The following examples show how to use
net.minecraft.tileentity.TileEntity#getWorld() .
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: Helper.java From ForgeHax with MIT License | 4 votes |
public static World getWorld(TileEntity tileEntity) { return tileEntity.getWorld(); }
Example 2
Source File: VSNetwork.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
/** * Don't use this! Use world.notifyBlockUpdate() instead! */ @Deprecated public static void sendTileToAllNearby(TileEntity tileEntity) { PlayerChunkMap playerChunkMap = ((WorldServer) tileEntity.getWorld()).playerChunkMap; playerChunkMap.markBlockForUpdate(tileEntity.getPos()); }
Example 3
Source File: Util.java From ExNihiloAdscensio with MIT License | 4 votes |
public static void dropItemInWorld(TileEntity source, EntityPlayer player, ItemStack stack, double speedfactor) { int hitOrientation = player == null ? 0 : MathHelper.floor(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; double stackCoordX = 0.0D, stackCoordY = 0.0D, stackCoordZ = 0.0D; switch (hitOrientation) { case 0: stackCoordX = source.getPos().getX() + 0.5D; stackCoordY = source.getPos().getY() + 0.5D + 1; stackCoordZ = source.getPos().getZ() - 0.25D; break; case 1: stackCoordX = source.getPos().getX() + 1.25D; stackCoordY = source.getPos().getY() + 0.5D + 1; stackCoordZ = source.getPos().getZ() + 0.5D; break; case 2: stackCoordX = source.getPos().getX() + 0.5D; stackCoordY = source.getPos().getY() + 0.5D + 1; stackCoordZ = source.getPos().getZ() + 1.25D; break; case 3: stackCoordX = source.getPos().getX() - 0.25D; stackCoordY = source.getPos().getY() + 0.5D + 1; stackCoordZ = source.getPos().getZ() + 0.5D; break; } EntityItem droppedEntity = new EntityItem(source.getWorld(), stackCoordX, stackCoordY, stackCoordZ, stack); if (player != null) { Vec3d motion = new Vec3d(player.posX - stackCoordX, player.posY - stackCoordY, player.posZ - stackCoordZ); motion.normalize(); droppedEntity.motionX = motion.xCoord; droppedEntity.motionY = motion.yCoord; droppedEntity.motionZ = motion.zCoord; double offset = 0.25D; droppedEntity.move(motion.xCoord * offset, motion.yCoord * offset, motion.zCoord * offset); } droppedEntity.motionX *= speedfactor; droppedEntity.motionY *= speedfactor; droppedEntity.motionZ *= speedfactor; droppedEntity.setNoPickupDelay(); source.getWorld().spawnEntity(droppedEntity); }
Example 4
Source File: RendererWarpCore.java From AdvancedRocketry with MIT License | 4 votes |
@Override public void render(TileEntity tile, double x, double y, double z, float f, int damage, float a) { TileMultiBlock multiBlockTile = (TileMultiBlock)tile; if(!multiBlockTile.canRender()) return; GL11.glPushMatrix(); //Rotate and move the model into position GL11.glTranslated(x + 0.5, y, z + 0.5); EnumFacing front = RotatableBlock.getFront(tile.getWorld().getBlockState(tile.getPos())); //tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)); GL11.glRotatef((front.getFrontOffsetX() == 1 ? 180 : 0) + front.getFrontOffsetZ()*90f, 0, 1, 0); GL11.glTranslated(1f, 0, 0f); bindTexture(texture); model.renderOnly("Base"); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING); GlStateManager.color(1f, 0.4f, 0.4f, 0.8f); GL11.glPushMatrix(); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderHelper.renderCubeWithUV(buffer, -0.1f, 1, -0.1f, 0.1f, 2, 0.1f, 0, 1, 0, 1); Tessellator.getInstance().draw(); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.color(1f, 1f,1f, 1f); if(tile.getWorld().provider instanceof WorldProviderSpace) { ISpaceObject obj = SpaceObjectManager.getSpaceManager().getSpaceStationFromBlockCoords(tile.getPos()); if(obj instanceof SpaceObject && ((SpaceObject)obj).getFuelAmount() > 50) { double speedMult = 1.5;//((DimensionProperties)obj.getProperties()).getParentPlanet() == SpaceObjectManager.WARPDIMID ? 1.5d : 0.1d; double speedRotate = speedMult*0.25d; GlStateManager.color(0.4f, 0.4f, 1f, 0.6f); GL11.glPushMatrix(); GL11.glRotated(speedRotate*System.currentTimeMillis() % 360, 0f, 1f, 0f); model.renderOnly("Rotate1"); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glRotated(180 + speedRotate*System.currentTimeMillis() % 360, 0f, 1f, 0f); model.renderOnly("Rotate1"); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glRotated(-speedRotate*System.currentTimeMillis() % 360, 0f, 1f, 0f); model.renderOnly("Rotate2"); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glRotated(180 -speedRotate*System.currentTimeMillis() % 360, 0f, 1f, 0f); model.renderOnly("Rotate2"); GL11.glPopMatrix(); speedRotate = 0.03d*speedMult; GlStateManager.color(0.4f, 1f, 0.4f, 0.8f); int amt = 3; float offset = 360/(float)amt; for(int j = 0; j < 5; j++) { for(int i = 0; i < amt; i++) { GL11.glPushMatrix(); GL11.glRotated(((j+1)*speedRotate*System.currentTimeMillis() % 360) + (i + j/5f)*offset, 0f, 1f, 0f); GL11.glTranslatef(0, 0.1f*j-.2f + (5-j)*0.02f*(float)Math.sin(0.001d*System.currentTimeMillis()), 0.2f); //GL11.glTranslatef(0f, 0.1f*(0.5f - MathHelper.sin((float)(0.001*System.currentTimeMillis() % 100))), 0f); model.renderOnly("Ball"); GL11.glPopMatrix(); } } } } GlStateManager.color(1f, 1f, 1f, 1f); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
Example 5
Source File: RendererCrystallizer.java From AdvancedRocketry with MIT License | 4 votes |
@Override public void render(TileEntity tile, double x, double y, double z, float f, int destroyStage, float a) { TileMultiblockMachine multiBlockTile = (TileMultiblockMachine)tile; if(!multiBlockTile.canRender()) return; GL11.glPushMatrix(); //Rotate and move the model into position GL11.glTranslated(x+.5f, y, z + 0.5f); EnumFacing front = RotatableBlock.getFront(tile.getWorld().getBlockState(tile.getPos())); //tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)); GL11.glRotatef((front.getFrontOffsetX() == 1 ? 180 : 0) + front.getFrontOffsetZ()*90f, 0, 1, 0); GL11.glTranslated(-.5f, 0, -1.5f); if(multiBlockTile.isRunning()) { float progress = multiBlockTile.getProgress(0)/(float)multiBlockTile.getTotalProgress(0); bindTexture(texture); model.renderPart("Hull"); List<ItemStack> outputList = multiBlockTile.getOutputs(); if(outputList != null && !outputList.isEmpty()) { ItemStack stack = outputList.get(0); EntityItem entity = new EntityItem(tile.getWorld()); entity.setItem(stack); entity.hoverStart = 0; int rotation = (int)(tile.getWorld().getTotalWorldTime() % 360); GL11.glPushMatrix(); GL11.glTranslatef(0, 1, 0); GL11.glPushMatrix(); GL11.glTranslated(1, 0.2, 0.7); GL11.glRotatef(rotation, 0, 1, 0); GL11.glScalef(progress, progress, progress); zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem()); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(1, 0.2, 1.5); GL11.glRotatef(rotation, 0, 1, 0); GL11.glScalef(progress, progress, progress); zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem()); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(1, 0.2, 2.3); GL11.glRotatef(rotation, 0, 1, 0); GL11.glScalef(progress, progress, progress); zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem()); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); int color = Minecraft.getMinecraft().getItemColors().getColorFromItemstack(stack, 0); float divisor = 1/255f; GL11.glColor4f((color & 0xFF)*divisor*.5f, ((color & 0xFF00) >>> 8)*divisor*.5f, ((color & 0xFF0000) >>> 16)*divisor*.5f, 0xE4*divisor); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glTranslatef(0, 1.1f, 0); //Fill before emptying if(progress < 0.05) GL11.glScaled(1, 20*progress, 1); else GL11.glScaled(1, (1.1-(progress*1.111)), 1); GL11.glTranslatef(0, -1.1f, 0); model.renderPart("Liquid"); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } else { bindTexture(texture); model.renderPart("Hull"); } GL11.glPopMatrix(); }
Example 6
Source File: WorldUtils.java From OpenModsLib with MIT License | 4 votes |
public static boolean isTileEntityValid(TileEntity te) { if (te.isInvalid()) return false; final World world = te.getWorld(); return (world != null)? world.isBlockLoaded(te.getPos()) : false; }