Java Code Examples for net.minecraft.tileentity.TileEntity#getWorldObj()

The following examples show how to use net.minecraft.tileentity.TileEntity#getWorldObj() . 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: ModelPressureChamberInterface.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderDynamic(float size, TileEntity te, float partialTicks){
    if(te instanceof TileEntityPressureChamberInterface) {
        TileEntityPressureChamberInterface tile = (TileEntityPressureChamberInterface)te;
        float renderInputProgress = tile.oldInputProgress + (tile.inputProgress - tile.oldInputProgress) * partialTicks;
        float renderOutputProgress = tile.oldOutputProgress + (tile.outputProgress - tile.oldOutputProgress) * partialTicks;
        renderModel(size, renderInputProgress / TileEntityPressureChamberInterface.MAX_PROGRESS, renderOutputProgress / TileEntityPressureChamberInterface.MAX_PROGRESS);
        if(tile.getStackInSlot(0) != null) {
            GL11.glTranslated(0, 17 / 16F, 0);
            GL11.glScalef(1.0F, -1F, -1F);
            // GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
            boolean fancySetting = RenderManager.instance.options.fancyGraphics;
            RenderManager.instance.options.fancyGraphics = true;
            EntityItem ghostItem = new EntityItem(te.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0));
            ghostItem.hoverStart = 0;
            customRenderItem.doRender(ghostItem, 0, 0, 0, 0, 0);
            RenderManager.instance.options.fancyGraphics = fancySetting;
        }
    } else {
        renderModel(size, 0, 0);
    }
}
 
Example 2
Source File: RenderTileRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private TileMirrorEssentia createFakeTile(TileEntity tile, boolean linked) {
    TileMirrorEssentia fake = new TileMirrorEssentia();
    fake.linked = linked;
    fake.blockMetadata = 7;

    if(tile.getWorldObj() == null) {
        fake.setWorldObj(new FakeWorld());
    } else {
        fake.setWorldObj(tile.getWorldObj());
    }

    if(tile.getWorldObj() instanceof FakeWorld) {
        EntityPlayer p = Minecraft.getMinecraft().thePlayer;
        fake.xCoord = (int) p.posX;
        fake.yCoord = (int) p.posY;
        fake.zCoord = (int) p.posZ;
    } else {
        fake.xCoord = tile.xCoord;
        fake.yCoord = tile.yCoord;
        fake.zCoord = tile.zCoord;
    }

    return fake;
}
 
Example 3
Source File: SegmentTileEntity.java    From MyTown2 with The Unlicense 6 votes vote down vote up
public boolean shouldExist(TileEntity te) {
    if(!shouldCheck(te)) {
        return true;
    }

    Volume teBox = new Volume(getX1(te), getY1(te), getZ1(te), getX2(te), getY2(te), getZ2(te));
    int dim = te.getWorldObj().provider.dimensionId;
    Resident owner;
    if(retainsOwner) {
        owner = ProtectionHandlers.instance.getOwnerForTileEntity(te);
    } else {
        owner = getOwner(te);
    }

    if (!hasPermissionAtLocation(owner, dim, teBox)) {
        return false;
    }

    return true;
}
 
Example 4
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public void removeTube(TileEntity te){
    if(te instanceof TileMultipart) {
        PartPressureTube tube = FMP.getMultiPart((TileMultipart)te, PartPressureTube.class);
        if(tube != null) {
            List<ItemStack> drops = BlockPressureTube.getModuleDrops(tube.getTube());
            for(ItemStack drop : drops) {
                EntityItem entity = new EntityItem(te.getWorldObj(), te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5);
                entity.setEntityItemStack(drop);
                te.getWorldObj().spawnEntityInWorld(entity);
            }
            ((TileMultipart)te).remPart(tube);
        }
    } else {
        super.removeTube(te);
    }
}
 
Example 5
Source File: WorldCoordinates.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 6
Source File: WorldCoordinates.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 7
Source File: WorldCoordinates.java    From GardenCollection with MIT License 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 8
Source File: WorldCoordinates.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 9
Source File: WorldCoordinates.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 10
Source File: WorldCoordinates.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
public WorldCoordinates(TileEntity tile)
{
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
    this.dim = tile.getWorldObj().provider.dimensionId;
}
 
Example 11
Source File: AdapterWorldInventory.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
private static IWorldPosProvider getProvider(IInventory target) {
	if (target instanceof IWorldPosProvider) return (IWorldPosProvider)target;
	if (target instanceof TileEntity) {
		final TileEntity te = (TileEntity)target;
		return new IWorldPosProvider() {

			@Override
			public boolean isValid() {
				return !te.isInvalid();
			}

			@Override
			public World getWorld() {
				return te.getWorldObj();
			}

			@Override
			public int getX() {
				return te.xCoord;
			}

			@Override
			public int getY() {
				return te.yCoord;
			}

			@Override
			public int getZ() {
				return te.zCoord;
			}
		};
	}

	throw new IllegalArgumentException("Invalid target object " + String.valueOf(target));
}
 
Example 12
Source File: AdapterWritingDesk.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
private NotebookWrapper createInventoryWrapper(TileEntity tile, Index slot) {
	ItemStack notebook = GET_NOTEBOOK.call(tile, slot.byteValue());
	Preconditions.checkState(notebook != null, "Empty slot");
	Item item = notebook.getItem();
	Preconditions.checkState(item instanceof IItemPageCollection, "Invalid item in slot");
	return new NotebookWrapper((WorldServer)tile.getWorldObj(), (IItemPageCollection)item, notebook);
}
 
Example 13
Source File: ItemRenderStoneMachine.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void registerRenderer(int metadata, TileEntity tile, TileEntitySpecialRenderer renderer) {
    RenderInfo info = new RenderInfo();
    info.renderer = renderer;
    info.tile = tile;
    renderers.put(metadata, info);

    if(tile.getWorldObj() == null) {
        tile.setWorldObj(FAKE_WORLD);
    }
}
 
Example 14
Source File: RenderTileCapEldritch.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
    if(te.getWorldObj().provider.dimensionId == ModConfig.dimOuterId) {
        int old = Config.dimensionOuterId;
        Config.dimensionOuterId = ModConfig.dimOuterId;
        super.renderTileEntityAt(te, x, y, z, f);
        Config.dimensionOuterId = old;
    } else {
        super.renderTileEntityAt(te, x, y, z, f);
    }
}
 
Example 15
Source File: TileEntityPneumaticBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void validateI(TileEntity parent){
    parentTile = parent;
    worldObj = parent.getWorldObj();
    xCoord = parent.xCoord;
    yCoord = parent.yCoord;
    zCoord = parent.zCoord;
}
 
Example 16
Source File: DimensionalCoord.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public DimensionalCoord(TileEntity s) {
	super( s );
	w = s.getWorldObj();
	dimId = w.provider.dimensionId;
}
 
Example 17
Source File: WorldCoordinate.java    From NEI-Integration with MIT License 4 votes vote down vote up
public WorldCoordinate(TileEntity tile) {
    this.dimension = tile.getWorldObj().provider.dimensionId;
    this.x = tile.xCoord;
    this.y = tile.yCoord;
    this.z = tile.zCoord;
}
 
Example 18
Source File: DimensionalCoord.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public DimensionalCoord( TileEntity s )
{
	super( s );
	this.w = s.getWorldObj();
	this.dimId = this.w.provider.dimensionId;
}
 
Example 19
Source File: RenderTileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTicks) {
    if(tileEntity == null || !(tileEntity instanceof TileEssentiaCompressor)) return;

    boolean isRenderedAsItem = false;
    if(tileEntity.getWorldObj() instanceof FakeWorld) { //LUL
        isRenderedAsItem = true;
    }

    if(!isRenderedAsItem && ((TileEssentiaCompressor) tileEntity).isMultiblockFormed()) {
        int yOffset = ((TileEssentiaCompressor) tileEntity).getMultiblockYIndex();
        GL11.glPushMatrix();
        GL11.glTranslated(x + 0.5, y - yOffset - 0.5, z + 0.5);
        bindTexture(COMPRESSOR_TEXTURE);
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glTranslatef(0, -2F, 0);
        MODEL_ESSENTIA_COMPRESSOR.render(null, 0, 0, 0, 0, 0, 0.0625f);
        GL11.glRotatef(180, 1, 0, 0);
        MODEL_ESSENTIA_COMPRESSOR.render(null, 0, 0, 0, 0, 0, 0.0625f);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        if(yOffset == 1) { //The middle one. - well. the one where the blackhole is.
            renderBlackHoleEffect(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5,
                    (TileEssentiaCompressor) tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord - 1, tileEntity.zCoord));
        }
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glTranslated(x + 0.5, y - 0.5, z + 0.5);
        GL11.glRotatef(180, 1, 0, 0);
        if(isRenderedAsItem) {
            GL11.glTranslatef(0, -2.9F, 0);
        } else {
            GL11.glTranslatef(0, -2.877F, 0);
        }
        bindTexture(PACKED_COMPRESSOR_TEXTURE);
        MODEL_PACKED_COMPRESSOR.render(null, 0, 0, 0, 0, 0, 0.0625f);
        GL11.glPopMatrix();
    }

}
 
Example 20
Source File: ITileWithGUI.java    From bartworks with MIT License 2 votes vote down vote up
/**
 * gets called from BW_TileEntityContainer(or _Multiple) when right clicked.
 *
 * @param tileEntity this tile entity
 * @param player     the player right clicking it
 * @return true always.
 */
default boolean openGUI(TileEntity tileEntity, EntityPlayer player) {
    if (!tileEntity.getWorldObj().isRemote)
        player.openGui(MainMod.MOD_ID, getGUIID(), tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
    return true;
}