Java Code Examples for net.minecraft.tileentity.TileEntity.getPos()

The following are Jave code examples for showing how to use getPos() of the net.minecraft.tileentity.TileEntity class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: WorldServer.java   View Source Code Vote up 6 votes
public List<TileEntity> getTileEntitiesIn(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
{
    List<TileEntity> list = Lists.<TileEntity>newArrayList();

    for (int i = 0; i < this.loadedTileEntityList.size(); ++i)
    {
        TileEntity tileentity = (TileEntity)this.loadedTileEntityList.get(i);
        BlockPos blockpos = tileentity.getPos();

        if (blockpos.getX() >= minX && blockpos.getY() >= minY && blockpos.getZ() >= minZ && blockpos.getX() < maxX && blockpos.getY() < maxY && blockpos.getZ() < maxZ)
        {
            list.add(tileentity);
        }
    }

    return list;
}
 
Example 2
Project: DecompiledMinecraft   File: WorldServer.java   View Source Code Vote up 6 votes
public List<TileEntity> getTileEntitiesIn(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
{
    List<TileEntity> list = Lists.<TileEntity>newArrayList();

    for (int i = 0; i < this.loadedTileEntityList.size(); ++i)
    {
        TileEntity tileentity = (TileEntity)this.loadedTileEntityList.get(i);
        BlockPos blockpos = tileentity.getPos();

        if (blockpos.getX() >= minX && blockpos.getY() >= minY && blockpos.getZ() >= minZ && blockpos.getX() < maxX && blockpos.getY() < maxY && blockpos.getZ() < maxZ)
        {
            list.add(tileentity);
        }
    }

    return list;
}
 
Example 3
Project: BaseClient   File: WorldServer.java   View Source Code Vote up 6 votes
public List<TileEntity> getTileEntitiesIn(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
{
    List<TileEntity> list = Lists.<TileEntity>newArrayList();

    for (int i = 0; i < this.loadedTileEntityList.size(); ++i)
    {
        TileEntity tileentity = (TileEntity)this.loadedTileEntityList.get(i);
        BlockPos blockpos = tileentity.getPos();

        if (blockpos.getX() >= minX && blockpos.getY() >= minY && blockpos.getZ() >= minZ && blockpos.getX() < maxX && blockpos.getY() < maxY && blockpos.getZ() < maxZ)
        {
            list.add(tileentity);
        }
    }

    return list;
}
 
Example 4
Project: BaseClient   File: WorldServer.java   View Source Code Vote up 6 votes
public List<TileEntity> getTileEntitiesIn(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
{
    List<TileEntity> list = Lists.<TileEntity>newArrayList();

    for (int i = 0; i < this.loadedTileEntityList.size(); ++i)
    {
        TileEntity tileentity = (TileEntity)this.loadedTileEntityList.get(i);
        BlockPos blockpos = tileentity.getPos();

        if (blockpos.getX() >= minX && blockpos.getY() >= minY && blockpos.getZ() >= minZ && blockpos.getX() < maxX && blockpos.getY() < maxY && blockpos.getZ() < maxZ)
        {
            list.add(tileentity);
        }
    }

    return list;
}
 
Example 5
Project: CustomWorldGen   File: World.java   View Source Code Vote up 6 votes
public boolean addTileEntity(TileEntity tile)
{
    if (tile.getWorld() != null) // Forge - set the world early as vanilla doesn't set it until next tick
        tile.setWorldObj(this);

    List<TileEntity> dest = processingLoadedTiles ? addedTileEntityList : loadedTileEntityList;
    boolean flag = dest.add(tile);

    if (flag && tile instanceof ITickable)
    {
        this.tickableTileEntities.add(tile);
    }

    if (this.isRemote)
    {
        BlockPos blockpos = tile.getPos();
        IBlockState iblockstate = this.getBlockState(blockpos);
        this.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 2);
    }

    return flag;
}
 
Example 6
Project: Backmemed   File: World.java   View Source Code Vote up 6 votes
public boolean addTileEntity(TileEntity tile)
{
    boolean flag = this.loadedTileEntityList.add(tile);

    if (flag && tile instanceof ITickable)
    {
        this.tickableTileEntities.add(tile);
    }

    if (this.isRemote)
    {
        BlockPos blockpos = tile.getPos();
        IBlockState iblockstate = this.getBlockState(blockpos);
        this.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 2);
    }

    return flag;
}
 
Example 7
Project: Backmemed   File: TileEntityRendererDispatcher.java   View Source Code Vote up 6 votes
public void renderTileEntity(TileEntity tileentityIn, float partialTicks, int destroyStage)
{
    if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn.getMaxRenderDistanceSquared())
    {
        RenderHelper.enableStandardItemLighting();
        boolean flag = true;

        if (Reflector.ForgeTileEntity_hasFastRenderer.exists())
        {
            flag = !this.drawingBatch || !Reflector.callBoolean(tileentityIn, Reflector.ForgeTileEntity_hasFastRenderer, new Object[0]);
        }

        if (flag)
        {
            int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0);
            int j = i % 65536;
            int k = i / 65536;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        }

        BlockPos blockpos = tileentityIn.getPos();
        this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);
    }
}
 
Example 8
Project: rezolve   File: GhostSlotUpdateMessage.java   View Source Code Vote up 5 votes
public GhostSlotUpdateMessage(EntityPlayerSP player, TileEntity entity, int slot, ItemStack itemStack) {
	this.playerId = player.getUniqueID().toString();
	
	BlockPos pos = entity.getPos();
	this.x = pos.getX();
	this.y = pos.getY();
	this.z = pos.getZ();
	
	this.slot = slot;
	this.stack = itemStack;
}
 
Example 9
Project: Dynamic-GUIs   File: ButtonHandler.java   View Source Code Vote up 5 votes
@SideOnly(Side.CLIENT)
public static void sendButtonPacket(TileEntity tile, int buttonID) {
	NBTTagCompound tag = new NBTTagCompound();
	BlockPos pos = tile.getPos();
	
	tag.setInteger("x", pos.getX());
	tag.setInteger("y", pos.getY());
	tag.setInteger("z", pos.getZ());
	
	tag.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId());
	tag.setInteger("ButtonID", buttonID);
	
	network.sendToServer(new PacketToServer(tag, ButtonHandler.GUI_BUTTON_HANDLER));
}
 
Example 10
Project: ForgeHax   File: SpawnerEspMod.java   View Source Code Vote up 5 votes
@SubscribeEvent
public void onRender(RenderEvent event) {
    event.getBuffer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

    for(TileEntity tileEntity : getWorld().loadedTileEntityList) {
        if(tileEntity instanceof TileEntityMobSpawner) {
            BlockPos pos = tileEntity.getPos();
            GeometryTessellator.drawCuboid(event.getBuffer(), pos, GeometryMasks.Line.ALL, Utils.Colors.RED);
        }
    }

    event.getTessellator().draw();
}
 
Example 11
Project: DecompiledMinecraft   File: TileEntityRendererDispatcher.java   View Source Code Vote up 5 votes
public void renderTileEntity(TileEntity tileentityIn, float partialTicks, int destroyStage)
{
    if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn.getMaxRenderDistanceSquared())
    {
        int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        BlockPos blockpos = tileentityIn.getPos();
        this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);
    }
}
 
Example 12
Project: BaseClient   File: TileEntityRendererDispatcher.java   View Source Code Vote up 5 votes
public void renderTileEntity(TileEntity tileentityIn, float partialTicks, int destroyStage)
{
    if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn.getMaxRenderDistanceSquared())
    {
        int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        BlockPos blockpos = tileentityIn.getPos();
        this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);
    }
}
 
Example 13
Project: EndermanEvolution   File: IronChests.java   View Source Code Vote up 5 votes
public static boolean canPlayerSilkHarvestChest(TileEntity te, EntityPlayer player) {
	if (!Mods.IRONCHESTS.isLoaded()) {
		return false;
	}
	BlockPos pos = te.getPos();
	Block block = te.getWorld() == null ? null : te.getWorld().getBlockState(pos).getBlock();
	return te != null && block != null && isIronChest(block) && player != null && player.getHeldItemMainhand() != null && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0 && !player.isCreative();
}
 
Example 14
Project: pnc-repressurized   File: PacketUpdateTextfield.java   View Source Code Vote up 4 votes
public PacketUpdateTextfield(TileEntity te, int textfieldID) {
    super(te.getPos());
    textFieldID = textfieldID;
    text = ((IGUITextFieldSensitive) te).getText(textfieldID);
}
 
Example 15
Project: pnc-repressurized   File: PacketSecurityStation.java   View Source Code Vote up 4 votes
public PacketSecurityStation(TileEntity te, String player) {
    super(te.getPos());
    this.username = player;
}
 
Example 16
Project: pnc-repressurized   File: PacketRenderRangeLines.java   View Source Code Vote up 4 votes
public PacketRenderRangeLines(TileEntity te) {
    super(te.getPos());
}
 
Example 17
Project: pnc-repressurized   File: PacketSendNBTPacket.java   View Source Code Vote up 4 votes
public PacketSendNBTPacket(TileEntity te) {
    super(te.getPos());
    tag = new NBTTagCompound();
    te.writeToNBT(tag);
}
 
Example 18
Project: pnc-repressurized   File: TileEntityAirCannon.java   View Source Code Vote up 4 votes
private void updateTrackedItems() {
    if (trackedItemIds != null) {
        trackedItems.clear();
        for (Entity entity : getWorld().loadedEntityList) {
            if (trackedItemIds.contains(entity.getUniqueID()) && entity instanceof EntityItem) {
                trackedItems.add((EntityItem) entity);
            }
        }
        trackedItemIds = null;
    }
    Iterator<EntityItem> iterator = trackedItems.iterator();
    while (iterator.hasNext()) {
        EntityItem item = iterator.next();
        if (item.world != getWorld() || item.isDead) {
            iterator.remove();
        } else {
            Map<BlockPos, EnumFacing> positions = new HashMap<>();
            double range = 0.2;
            for (EnumFacing d : EnumFacing.VALUES) {
                double posX = item.posX + d.getFrontOffsetX() * range;
                double posY = item.posY + d.getFrontOffsetY() * range;
                double posZ = item.posZ + d.getFrontOffsetZ() * range;
                positions   .put(new BlockPos((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)), d.getOpposite());
            }
            for (Entry<BlockPos, EnumFacing> entry : positions.entrySet()) {
                BlockPos pos = entry.getKey();
                TileEntity te = getWorld().getTileEntity(pos);
                if (te == null) continue;
                IItemHandler inv = IOHelper.getInventoryForTE(te, entry.getValue());
                ItemStack remainder = ItemHandlerHelper.insertItem(inv, item.getItem(), false);
                if (!remainder.isEmpty()) {
                    item.setItem(remainder);
                } else {
                    item.setDead();
                    iterator.remove();
                    lastInsertingInventory = te.getPos();
                    lastInsertingInventorySide = entry.getValue();
                    break;
                }
            }
        }
    }
}
 
Example 19
Project: OpenFlexiTrack   File: TileEntitySurveyFlag.java   View Source Code Vote up 4 votes
/**
 * Spawns dummy tracks based on flag linking.
 * 
 * @return {@code null} if successful, otherwise the {@link net.minecraft.util.math.BlockPos BlockPos} of the first obstructing block.
 */
public BlockPos spawnDummyTracks() {

	/*
	 * Make sure other tile entity is a flag.
	 */
	TileEntity tile = worldObj.getTileEntity(this.pos.add(linkedCurve.endPos));
	if (!(tile instanceof TileEntitySurveyFlag)) {
		return tile.getPos();
	}

	float width = getSleeperType().getDefaultWidth() - 1.0F;
	if (width <= 0.0F) {
		width = 0.0F;
	}

	final int ballast = MathHelper.ceiling_float_int( width / 2.0F );
	final OFTCurve thisFlagCurve = linkedCurve;
	final OFTCurve otherFlagCurve = ((TileEntitySurveyFlag) tile).linkedCurve;
	final Map<BlockPos, Byte> blockMap = new HashMap<BlockPos, Byte>();

	/*
	 * Need to see which end of the curve is higher.
	 * If we go top-down, the fake tracks are too high and ballast looks weird.
	 * On the other hand, if we went from the other direction we might miss ballast below the track.
	 * Steep hills tend to do this, so go in both directions just in case.
	 */
	BlockPos blockingBlock = addFakeTracksToMap(thisFlagCurve, this.pos, blockMap, ballast);
	if(blockingBlock != null){
		return blockingBlock;
	}
	blockingBlock = addFakeTracksToMap(otherFlagCurve, this.pos.add(linkedCurve.endPos), blockMap, ballast);
	if(blockingBlock != null){
		return blockingBlock;
	}

	/*
	 * Finally create fake tracks.
	 */
	BlockTrackFake.toggleMainTrackBreakage(false);
	{
		/* Set block states at selected positions. */
		IBlockState defState = OFTRegistry.trackStructureFake.getDefaultState();

		for (BlockPos placementPos : blockMap.keySet()) {
			worldObj.setBlockState(placementPos, defState.withProperty(BlockTrackFake.height, (int) blockMap.get(placementPos)));			
		}

		/* Set block states and tile entities at start and end. */
		worldObj.setBlockState(this.pos, OFTRegistry.trackStructure.getDefaultState());
		worldObj.setBlockState(this.pos.add(thisFlagCurve.endPos), OFTRegistry.trackStructure.getDefaultState());
		TileEntityTrack startTile = new TileEntityTrack(thisFlagCurve);
		TileEntityTrack endTile = new TileEntityTrack(otherFlagCurve);
		startTile.setFakeTracks(new ArrayList<BlockPos>(blockMap.keySet()));
		endTile.setFakeTracks(new ArrayList<BlockPos>(blockMap.keySet()));
		worldObj.setTileEntity(this.pos, startTile);
		worldObj.setTileEntity(this.pos.add(thisFlagCurve.endPos), endTile);
	}
	BlockTrackFake.toggleMainTrackBreakage(true);

	return null;
}
 
Example 20
Project: EndermanEvolution   File: ChestUtils.java   View Source Code Vote up 4 votes
public static boolean canPlayerSilkHarvestChest(TileEntity te, EntityPlayer player) {
	BlockPos pos = te.getPos();
	Block block = te.getWorld() == null ? null : te.getWorld().getBlockState(pos).getBlock();
	return te != null && block != null && ChestUtils.isVanillaChest(block, false) && player != null && player.getHeldItemMainhand() != null && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0 && !player.isCreative();
}