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

The following examples show how to use net.minecraft.tileentity.TileEntity#getPos() . 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: TileEntityGnomeCache.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Iterates over the list of loaded tile entities once per tick to find a chest
 * Returns a position of the chest if a chest is found with at least one item in it
 * @return
 */
public BlockPos findTargetChest()
{
	List<TileEntity> list = this.world.loadedTileEntityList;
	if (this.target_chest_iter >= list.size())
	{
		this.target_chest_iter = 0;
	}
	TileEntity potential_entity = (TileEntity) list.get(this.target_chest_iter);
	BlockPos tepos = potential_entity.getPos();
	this.target_chest_iter++;
	if (potential_entity != null && this.world.getBlockState(tepos).getBlock() == Blocks.CHEST)
	{
		// TODO maybe put a try/catch here? (life should go on)
		TileEntityChest chestent = (TileEntityChest)potential_entity;
		for (int i = 0; i < chestent.getSizeInventory(); i++)
		{
			if (chestent.getStackInSlot(i) != null)
			{
				return tepos;
			}
		}
	}
	return null;
}
 
Example 2
Source File: TickHandler.java    From GokiStats with MIT License 6 votes vote down vote up
private void handleFurnace(EntityPlayer player) {
    if (DataHelper.getPlayerStatLevel(player, Stats.FURNACE_FINESSE) > 0) {
        ArrayList<TileEntityFurnace> furnacesAroundPlayer = new ArrayList<>();

        for (TileEntity listEntity : player.world.loadedTileEntityList) {
            if (listEntity != null) {
                TileEntity tileEntity = listEntity;
                BlockPos pos = tileEntity.getPos();
                if (tileEntity instanceof TileEntityFurnace && MathHelper.sqrt(player.getDistanceSq(pos)) < 4.0D) {
                    // TODO work out alter way to do tileEntity
                    furnacesAroundPlayer.add((TileEntityFurnace) tileEntity);
                }
            }
        }

        // FIXME Laggy
        for (TileEntityFurnace furnace : furnacesAroundPlayer)
            if (furnace.isBurning())
                for (int i = 0; i < Stats.FURNACE_FINESSE.getBonus(player); i++) // Intend to "mount" ticks, same as Torcherino.
                    furnace.update();
    }

}
 
Example 3
Source File: SpawnerEspMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@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, Colors.RED.toBuffer());
    }
  }
  
  event.getTessellator().draw();
}
 
Example 4
Source File: TileLandingPad.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean onLinkComplete(ItemStack item, TileEntity entity,
		EntityPlayer player, World world) {

	TileEntity tile = world.getTileEntity(ItemLinker.getMasterCoords(item));

	if(tile instanceof IInfrastructure) {
		HashedBlockPosition pos = new HashedBlockPosition(tile.getPos());
		if(!blockPos.contains(pos)) {
			blockPos.add(pos);
		}

		AxisAlignedBB bbCache =  new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1));


		List<EntityRocketBase> rockets = world.getEntitiesWithinAABB(EntityRocketBase.class, bbCache);
		for(EntityRocketBase rocket : rockets) {
			rocket.linkInfrastructure((IInfrastructure) tile);
		}


		if(!world.isRemote) {
			player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.success")));

			if(tile instanceof IMultiblock)
				((IMultiblock)tile).setMasterBlock(getPos());
		}

		ItemLinker.resetPosition(item);
		return true;
	}
	return false;
}
 
Example 5
Source File: TileRocketBuilder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean onLinkComplete(ItemStack item, TileEntity entity,
		EntityPlayer player, World world) {
	TileEntity tile = world.getTileEntity(ItemLinker.getMasterCoords(item));

	if(tile instanceof IInfrastructure) {
		HashedBlockPosition pos = new HashedBlockPosition(tile.getPos());
		if(!blockPos.contains(pos))
			blockPos.add(pos);

		if(getBBCache() == null) {
			bbCache = getRocketPadBounds(world, getPos());
		}

		if(getBBCache() != null) {

			List<EntityRocketBase> rockets = world.getEntitiesWithinAABB(EntityRocketBase.class, bbCache);
			for(EntityRocketBase rocket : rockets) {
				rocket.linkInfrastructure((IInfrastructure) tile);
			}
		}

		if(!world.isRemote) {
			player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.success")));

			if(tile instanceof IMultiblock)
				((IMultiblock)tile).setMasterBlock(getPos());
		}

		ItemLinker.resetPosition(item);
		return true;
	}
	return false;
}
 
Example 6
Source File: TofuNetwork.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public Stream<Map.Entry<String, TileEntity>> getTEWithinRadius(TileEntity center, double radius) {
    BlockPos pos = center.getPos();
    return getTEWithinDim(center.getWorld().provider.getDimension())
            .filter(entry -> entry.getValue().getPos().getDistance(pos.getX(), pos.getY(), pos.getZ()) <= radius);
}
 
Example 7
Source File: MixinTileEntityRendererDispatcher.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Inject(method = "render(Lnet/minecraft/tileentity/TileEntity;FI)V",
    at = @At("HEAD"),
    cancellable = true)
private void preRender(TileEntity tileentityIn, float partialTicks, int destroyStage,
    CallbackInfo callbackInfo) {
    if (!hasChanged) {
        BlockPos pos = tileentityIn.getPos();
        Optional<PhysicsObject> physicsObject = ValkyrienUtils
            .getPhysicsObject(tileentityIn.getWorld(), tileentityIn.getPos());

        if (physicsObject.isPresent()) {
            try {
                GlStateManager.resetColor();

                if (drawingBatch) {
                    this.drawBatch(MinecraftForgeClient.getRenderPass());
                    this.preDrawBatch();
                }

                physicsObject.get()
                    .getShipRenderer()
                    .applyRenderTransform(partialTicks);

                double playerX = TileEntityRendererDispatcher.staticPlayerX;
                double playerY = TileEntityRendererDispatcher.staticPlayerY;
                double playerZ = TileEntityRendererDispatcher.staticPlayerZ;

                TileEntityRendererDispatcher.staticPlayerX = physicsObject.get()
                    .getShipRenderer().offsetPos.getX();
                TileEntityRendererDispatcher.staticPlayerY = physicsObject.get()
                    .getShipRenderer().offsetPos.getY();
                TileEntityRendererDispatcher.staticPlayerZ = physicsObject.get()
                    .getShipRenderer().offsetPos.getZ();

                hasChanged = true;
                if (drawingBatch) {
                    this.render(tileentityIn, partialTicks, destroyStage);
                    this.drawBatch(MinecraftForgeClient.getRenderPass());
                    this.preDrawBatch();
                } else {
                    this.render(tileentityIn, partialTicks, destroyStage);
                }
                hasChanged = false;
                TileEntityRendererDispatcher.staticPlayerX = playerX;
                TileEntityRendererDispatcher.staticPlayerY = playerY;
                TileEntityRendererDispatcher.staticPlayerZ = playerZ;

                physicsObject.get()
                    .getShipRenderer()
                    .inverseTransform(partialTicks);
            } catch (Exception e) {
                e.printStackTrace();
            }
            callbackInfo.cancel();
        }
    }
}
 
Example 8
Source File: PacketHandler.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
public static void sendToAllAround(IMessage message, TileEntity te, int range) 
{
	BlockPos pos = te.getPos();
       INSTANCE.sendToAllAround(message, new TargetPoint(te.getWorld().provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), range));
   }
 
Example 9
Source File: PacketUpdateTextfield.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
public PacketUpdateTextfield(TileEntity te, int textfieldID){
    super(te.getPos());
    textFieldID = textfieldID;
    text = ((IGUITextFieldSensitive)te).getText(textfieldID);
}
 
Example 10
Source File: PacketUpdateMessage.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
public PacketUpdateMessage(TileEntity te, EntityMinecart cart, String message, String... args){
    super(te.getPos());
    entityId = cart.getEntityId();
    this.message = message;
    this.args = args;
}
 
Example 11
Source File: BlockCoord.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BlockCoord(TileEntity tile) {
    this(tile.getPos());
}
 
Example 12
Source File: Vector3.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Vector3 fromTile(TileEntity tile) {
    return new Vector3(tile.getPos());
}
 
Example 13
Source File: BlockEventPacket.java    From OpenModsLib with MIT License 4 votes vote down vote up
public BlockEventPacket(TileEntity tile) {
	this(tile.getWorld().provider.getDimension(), tile.getPos());
}
 
Example 14
Source File: SimpleNetTileEntity.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static SPacketUpdateTileEntity writeToPacket(TileEntity te) {
	NBTTagCompound data = new NBTTagCompound();
	te.writeToNBT(data);
	return new SPacketUpdateTileEntity(te.getPos(), 42, data);
}
 
Example 15
Source File: VSGuiButtonMessage.java    From Valkyrien-Skies with Apache License 2.0 2 votes vote down vote up
/**
 * Client constructor
 *
 * @param tileEntity
 * @param buttonId
 */
public VSGuiButtonMessage(TileEntity tileEntity, int buttonId) {
    this.tileEntityPos = tileEntity.getPos();
    this.buttonId = buttonId;
}