use of de.canitzp.tumat.api.components.DescriptionComponent in project TUMAT by canitzp.
the class RenderOverlay method renderEntity.
private static TooltipComponent renderEntity(WorldClient world, EntityPlayerSP player, Entity entity, boolean shouldCalculate) {
TooltipComponent component = new TooltipComponent();
if (ConfigBoolean.SHOW_DROPPED_ITEMS.value && entity instanceof EntityItem) {
component.setName(new TextComponent(L10n.getItemText(InfoUtil.getItemName(((EntityItem) entity).getItem()) + TextFormatting.RESET, String.valueOf(((EntityItem) entity).getItem().getCount()))));
component.add(new DescriptionComponent(((EntityItem) entity).getItem()), TooltipComponent.Priority.LOW);
component.setModName(new TextComponent(InfoUtil.getModName(((EntityItem) entity).getItem().getItem())));
component.setIconRenderer(new IconRenderer(((EntityItem) entity).getItem()));
for (IWorldRenderer renderer : TUMATApi.getRegisteredComponents()) {
if (renderer.shouldBeActive()) {
renderer.renderEntityItem(world, player, (EntityItem) entity, ((EntityItem) entity).getItem(), component, shouldCalculate);
}
}
} else if (ConfigBoolean.SHOW_ENTITIES.value && entity instanceof EntityLivingBase) {
component.setName(new TextComponent(InfoUtil.getEntityName(entity)));
component.add(new TextComponent(TextFormatting.RED.toString() + ((EntityLivingBase) entity).getHealth() + "/" + ((EntityLivingBase) entity).getMaxHealth()), TooltipComponent.Priority.HIGH);
component.setModName(new TextComponent(InfoUtil.getModName(entity)));
ResourceLocation res = EntityList.getKey(entity);
if (res != null) {
ItemStack spawnEgg = new ItemStack(Items.SPAWN_EGG);
ItemMonsterPlacer.applyEntityIdToItemStack(spawnEgg, res);
component.setIconRenderer(new IconRenderer(spawnEgg));
}
for (IWorldRenderer renderer : TUMATApi.getRegisteredComponents()) {
if (renderer.shouldBeActive()) {
renderer.renderLivingEntity(world, player, (EntityLivingBase) entity, component, shouldCalculate);
}
}
} else if (ConfigBoolean.SHOW_ENTITIES.value) {
component.setName(new TextComponent(InfoUtil.getEntityName(entity)));
component.setModName(new TextComponent(InfoUtil.getModName(entity)));
for (IWorldRenderer renderer : TUMATApi.getRegisteredComponents()) {
if (renderer.shouldBeActive()) {
renderer.renderEntity(world, player, entity, component, shouldCalculate);
}
}
}
return component;
}
use of de.canitzp.tumat.api.components.DescriptionComponent in project TUMAT by canitzp.
the class RenderOverlay method renderBlock.
private static TooltipComponent renderBlock(WorldClient world, EntityPlayerSP player, BlockPos pos, EnumFacing side, boolean shouldCalculate) {
TooltipComponent component = new TooltipComponent();
if (!world.isAirBlock(pos)) {
IBlockState state = world.getBlockState(pos);
component.setName(TextComponent.createWithSensitiveName(world, player, savedTrace, pos, state));
component.add(new DescriptionComponent(InfoUtil.newStackFromBlock(world, pos, state, player, savedTrace)), TooltipComponent.Priority.LOW);
component.setModName(new TextComponent(InfoUtil.getModName(state.getBlock())));
for (IWorldRenderer renderer : TUMATApi.getRegisteredComponents()) {
if (renderer.shouldBeActive()) {
renderer.renderBlock(world, player, pos, side, component, shouldCalculate);
TileEntity tile = world.getTileEntity(pos);
if (ConfigBoolean.SHOW_TILES.value && tile != null) {
try {
renderer.renderTileEntity(world, player, tile, side, component, shouldCalculate);
} catch (Exception e) {
component.add(new DescriptionComponent(Lists.newArrayList("An error occured", "while getting tile data!")), TooltipComponent.Priority.HIGH);
if (world.getTotalWorldTime() % 150 == 0) {
TUMAT.logger.error("An error occured while getting tile data from: " + state.getBlock().getUnlocalizedName() + " at: " + pos, e);
}
}
}
component.setIconRenderer(renderer.getIconRenderObject(world, player, pos, side, savedTrace, shouldCalculate));
}
}
} else {
return null;
}
return component;
}
use of de.canitzp.tumat.api.components.DescriptionComponent in project TUMAT by canitzp.
the class TUMATEvents method gameOverlayRenderEvent.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void gameOverlayRenderEvent(RenderGameOverlayEvent.Post event) {
if (ConfigBoolean.SHOULD_TUMAT_RENDER.value && event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.currentScreen == null || TUMATApi.getAllowedGuis().contains(mc.currentScreen.getClass())) {
try {
if (TUMAT.DEBUG) {
String tumat = TextFormatting.AQUA.toString() + "T" + TextFormatting.GREEN.toString() + "U" + TextFormatting.RED.toString() + "M" + TextFormatting.YELLOW.toString() + "A" + TextFormatting.AQUA.toString() + "T" + TextFormatting.RESET.toString();
String buildText = tumat + " build " + TUMAT.BUILD_DATE;
GlStateManager.pushMatrix();
GlStateManager.scale(0.4F, 0.4F, 0.4F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
Minecraft.getMinecraft().fontRenderer.drawString(buildText, 2, 2, 0x80FFFFFF);
GlStateManager.popMatrix();
}
RenderOverlay.render(mc.world, mc.player, mc.fontRenderer, event.getPartialTicks(), mc.world.getTotalWorldTime() % 3 == 0);
} catch (Exception e) {
InfoUtil.drawCenteredString(mc.fontRenderer, L10n.ERROR_TEXT, GuiTUMAT.getXFromPercantage(), GuiTUMAT.getYFromPercantage(), 0xFFFFFF);
RenderOverlay.renderComponents(mc.fontRenderer, new TooltipComponent().setName(new TextComponent(L10n.ERROR_TEXT)).add(new DescriptionComponent(Lists.newArrayList("")), TooltipComponent.Priority.HIGH));
if (mc.world.getTotalWorldTime() % 100 == 0) {
TUMAT.logger.error("An Error occurred while rendering the tooltip.", e);
e.printStackTrace();
}
}
}
}
}
use of de.canitzp.tumat.api.components.DescriptionComponent in project TUMAT by canitzp.
the class StorageDrawers method renderTileEntity.
@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
if (player.isSneaking() && tileEntity instanceof TileEntityDrawers) {
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
if (handler != null) {
List<String> lines = new ArrayList<>();
for (int i = 1; i < handler.getSlots(); i++) {
ItemStack stack = handler.getStackInSlot(i);
if (!stack.isEmpty()) {
lines.add(L10n.getStorageDrawersContent(i, InfoUtil.getItemName(stack)));
} else {
lines.add(L10n.getStorageDrawersContent(i, TextFormatting.WHITE + L10n.EMPTY));
}
}
component.add(new DescriptionComponent(lines), TooltipComponent.Priority.HIGH);
}
} else {
component.add(new TextComponent(L10n.SNEAKFORMORE).setScale(0.8F).setFormat(TextFormatting.GRAY), TooltipComponent.Priority.HIGH);
}
}
return component;
}
use of de.canitzp.tumat.api.components.DescriptionComponent in project TUMAT by canitzp.
the class IndustrialCraft2 method renderTileEntity.
@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
if (tileEntity instanceof TileEntityBlock) {
InfoUtil.syncTileEntity(tileEntity, shouldCalculate, "components");
if (((TileEntityBlock) tileEntity).hasComponent(Energy.class)) {
Energy energy = ((TileEntityBlock) tileEntity).getComponent(Energy.class);
List<String> desc = new ArrayList<>();
if (ConfigBoolean.SHOW_EU.value) {
if (!(tileEntity instanceof IEnergyStorage)) {
int stored = (int) energy.getEnergy();
int cap = (int) energy.getCapacity();
if (cap > 0) {
if (cap < stored) {
cap = stored;
}
component.add(new EnergyComponent(stored, cap, "EU", TextFormatting.YELLOW), TooltipComponent.Priority.HIGH);
}
}
if (!energy.getSourceDirs().isEmpty()) {
desc.add(Localization.translate("ic2.item.tooltip.PowerTier", energy.getSourceTier()));
} else if (!energy.getSinkDirs().isEmpty()) {
desc.add(Localization.translate("ic2.item.tooltip.PowerTier", energy.getSinkTier()));
}
}
if (tileEntity instanceof TileEntityTransformer) {
desc.add(String.format("%s %.0f %s %s %.0f %s", Localization.translate("ic2.item.tooltip.Low"), EnergyNet.instance.getPowerFromTier(energy.getSinkTier()), Localization.translate("ic2.generic.text.EUt"), Localization.translate("ic2.item.tooltip.High"), EnergyNet.instance.getPowerFromTier(energy.getSourceTier() + 1), Localization.translate("ic2.generic.text.EUt")));
}
component.clear(TooltipComponent.Priority.LOW);
component.add(new DescriptionComponent(desc), TooltipComponent.Priority.LOW);
}
}
if (tileEntity instanceof TileEntityCable) {
InfoUtil.syncTileEntity(tileEntity, shouldCalculate, "cableType", "insulation");
NBTTagCompound nbt = new NBTTagCompound();
tileEntity.writeToNBT(nbt);
if (!nbt.hasNoTags()) {
try {
CableType cableType = CableType.values[nbt.getByte("cableType") & 255];
int insulation = nbt.getByte("insulation") & 255;
ItemStack cable = ItemCable.getCable(cableType, insulation);
component.setName(new TextComponent(InfoUtil.getItemName(cable)));
component.clear(TooltipComponent.Priority.LOW);
component.add(new DescriptionComponent(cable), TooltipComponent.Priority.LOW);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return component;
}
Aggregations