mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 23:11:40 +01:00
refactor to the goggle overlay system
added interface IHaveGoggleInformation to be implemented by TileEntities that want to display stuff on screen
This commit is contained in:
parent
cbc5eaebf9
commit
1dd68bf427
12 changed files with 315 additions and 286 deletions
|
@ -107,7 +107,7 @@ public class ItemDescription {
|
||||||
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
||||||
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||||
int index = impactId.ordinal();
|
int index = impactId.ordinal();
|
||||||
String level = impactId.getColor() + makeProgressBar(3, index) + stressLevels.get(index);
|
String level = impactId.getAbsoluteColor() + makeProgressBar(3, index) + stressLevels.get(index);
|
||||||
|
|
||||||
if (hasGlasses)
|
if (hasGlasses)
|
||||||
level += " (" + impacts.get(id).get() + stressUnit + ")";
|
level += " (" + impacts.get(id).get() + stressUnit + ")";
|
||||||
|
@ -122,8 +122,8 @@ public class ItemDescription {
|
||||||
double capacity = capacities.get(id).get();
|
double capacity = capacities.get(id).get();
|
||||||
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW
|
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW
|
||||||
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
|
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
|
||||||
int index = StressImpact.values().length - 1 - impactId.ordinal();
|
int index = StressImpact.values().length - 2 - impactId.ordinal();
|
||||||
String level = impactId.getColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index);
|
String level = impactId.getAbsoluteColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index);
|
||||||
|
|
||||||
if (hasGlasses)
|
if (hasGlasses)
|
||||||
level += " (" + capacity + stressUnit + ")";
|
level += " (" + capacity + stressUnit + ")";
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package com.simibubi.create.modules.contraptions.base;
|
package com.simibubi.create.modules.contraptions.base;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.KineticNetwork;
|
import com.simibubi.create.modules.contraptions.KineticNetwork;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
|
public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
|
||||||
|
|
||||||
|
@ -42,6 +47,32 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
boolean added = super.addToGoggleTooltip(tooltip, isPlayerSneaking);
|
||||||
|
|
||||||
|
float stressBase = getAddedStressCapacity();
|
||||||
|
if (stressBase != 0 && IRotate.StressImpact.isEnabled()) {
|
||||||
|
tooltip.add(spacing + Lang.translate("gui.goggles.generator_stats"));
|
||||||
|
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.capacityProvided"));
|
||||||
|
|
||||||
|
float speed = getTheoreticalSpeed();
|
||||||
|
if (speed != getGeneratedSpeed() && speed != 0)
|
||||||
|
stressBase *= getGeneratedSpeed() / speed;
|
||||||
|
|
||||||
|
speed = Math.abs(speed);
|
||||||
|
float stressTotal = stressBase * speed;
|
||||||
|
|
||||||
|
String stressString = spacing + "%s%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s";
|
||||||
|
tooltip.add(String.format(stressString, TextFormatting.AQUA, IHaveGoggleInformation.format(stressBase), Lang.translate("gui.goggles.base_value")));
|
||||||
|
tooltip.add(String.format(stressString, TextFormatting.GRAY, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed")));
|
||||||
|
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateGeneratedRotation() {
|
public void updateGeneratedRotation() {
|
||||||
float speed = getGeneratedSpeed();
|
float speed = getGeneratedSpeed();
|
||||||
float prevSpeed = this.speed;
|
float prevSpeed = this.speed;
|
||||||
|
@ -122,5 +153,4 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
|
||||||
public Long createNetworkId() {
|
public Long createNetworkId() {
|
||||||
return pos.toLong();
|
return pos.toLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.simibubi.create.modules.contraptions.base;
|
package com.simibubi.create.modules.contraptions.base;
|
||||||
|
|
||||||
import com.simibubi.create.config.AllConfigs;
|
import com.simibubi.create.config.AllConfigs;
|
||||||
|
import com.simibubi.create.foundation.item.ItemDescription;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.IWrenchable;
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -12,7 +15,7 @@ import net.minecraft.world.IWorldReader;
|
||||||
|
|
||||||
public interface IRotate extends IWrenchable {
|
public interface IRotate extends IWrenchable {
|
||||||
|
|
||||||
public enum SpeedLevel {
|
enum SpeedLevel {
|
||||||
NONE,
|
NONE,
|
||||||
MEDIUM,
|
MEDIUM,
|
||||||
FAST;
|
FAST;
|
||||||
|
@ -53,20 +56,65 @@ public interface IRotate extends IWrenchable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFormattedSpeedText(float speed, boolean overstressed){
|
||||||
|
SpeedLevel speedLevel = of(speed);
|
||||||
|
|
||||||
|
String color;
|
||||||
|
if (overstressed)
|
||||||
|
color = TextFormatting.DARK_GRAY + "" + TextFormatting.STRIKETHROUGH;
|
||||||
|
else
|
||||||
|
color = speedLevel.getTextColor() + "";
|
||||||
|
|
||||||
|
String level = color + ItemDescription.makeProgressBar(3, speedLevel.ordinal());
|
||||||
|
|
||||||
|
if (speedLevel == SpeedLevel.MEDIUM)
|
||||||
|
level += Lang.translate("tooltip.speedRequirements.medium");
|
||||||
|
if (speedLevel == SpeedLevel.FAST)
|
||||||
|
level += Lang.translate("tooltip.speedRequirements.high");
|
||||||
|
|
||||||
|
level += String.format(" (%s%s) ", IHaveGoggleInformation.format(Math.abs(speed)), Lang.translate("generic.unit.rpm"));
|
||||||
|
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StressImpact {
|
enum StressImpact {
|
||||||
LOW,
|
LOW,
|
||||||
MEDIUM,
|
MEDIUM,
|
||||||
HIGH;
|
HIGH,
|
||||||
|
OVERSTRESSED;
|
||||||
|
|
||||||
public TextFormatting getColor() {
|
public TextFormatting getAbsoluteColor() {
|
||||||
return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED;
|
return this == LOW ? TextFormatting.YELLOW : this == MEDIUM ? TextFormatting.GOLD : TextFormatting.RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextFormatting getRelativeColor() {
|
||||||
|
return this == LOW ? TextFormatting.GREEN : this == MEDIUM ? TextFormatting.YELLOW : this == HIGH ? TextFormatting.GOLD : TextFormatting.RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StressImpact of(double stressPercent){
|
||||||
|
if (stressPercent > 1) return StressImpact.OVERSTRESSED;
|
||||||
|
else if (stressPercent > .75d) return StressImpact.HIGH;
|
||||||
|
else if (stressPercent > .5d) return StressImpact.MEDIUM;
|
||||||
|
else return StressImpact.LOW;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEnabled() {
|
public static boolean isEnabled() {
|
||||||
return !AllConfigs.SERVER.kinetics.disableStress.get();
|
return !AllConfigs.SERVER.kinetics.disableStress.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFormattedStressText(double stressPercent){
|
||||||
|
StressImpact stressLevel = of(stressPercent);
|
||||||
|
TextFormatting color = stressLevel.getRelativeColor();
|
||||||
|
|
||||||
|
String level = color + ItemDescription.makeProgressBar(3, stressLevel.ordinal());
|
||||||
|
level += Lang.translate("tooltip.stressImpact."+Lang.asId(stressLevel.name()));
|
||||||
|
|
||||||
|
level += String.format(" (%s%%) ", (int) (stressPercent * 100));
|
||||||
|
|
||||||
|
return level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face);
|
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face);
|
||||||
|
|
|
@ -10,12 +10,16 @@ import com.simibubi.create.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||||
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
|
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
|
||||||
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
||||||
|
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.KineticNetwork;
|
import com.simibubi.create.modules.contraptions.KineticNetwork;
|
||||||
import com.simibubi.create.modules.contraptions.RotationPropagator;
|
import com.simibubi.create.modules.contraptions.RotationPropagator;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact;
|
import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
@ -23,10 +27,13 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||||
|
|
||||||
public abstract class KineticTileEntity extends SmartTileEntity implements ITickableTileEntity {
|
import static net.minecraft.util.text.TextFormatting.GRAY;
|
||||||
|
|
||||||
|
public abstract class KineticTileEntity extends SmartTileEntity implements ITickableTileEntity, IHaveGoggleInformation {
|
||||||
|
|
||||||
public @Nullable Long network;
|
public @Nullable Long network;
|
||||||
public @Nullable BlockPos source;
|
public @Nullable BlockPos source;
|
||||||
|
@ -346,6 +353,36 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
boolean added = false;
|
||||||
|
float stressAtBase = getStressApplied();
|
||||||
|
|
||||||
|
boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0;
|
||||||
|
|
||||||
|
if (notFastEnough) {
|
||||||
|
tooltip.addAll(TooltipHelper.cutString(spacing + Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock().getTranslationKey())), GRAY, TextFormatting.WHITE));
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getStressApplied() != 0 && StressImpact.isEnabled()){
|
||||||
|
tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats"));
|
||||||
|
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.stressImpact"));
|
||||||
|
|
||||||
|
float stressTotal = stressAtBase * Math.abs(getSpeed());
|
||||||
|
|
||||||
|
String stressString = spacing + "%s%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s";
|
||||||
|
|
||||||
|
tooltip.add(String.format(stressString, TextFormatting.AQUA, IHaveGoggleInformation.format(stressAtBase), Lang.translate("gui.goggles.base_value")));
|
||||||
|
tooltip.add(String.format(stressString, TextFormatting.GRAY, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed")));
|
||||||
|
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return added;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public int getFlickerScore() {
|
public int getFlickerScore() {
|
||||||
return flickerTally;
|
return flickerTally;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.simibubi.create.modules.contraptions.goggle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
|
@EventBusSubscriber(value = Dist.CLIENT)
|
||||||
|
public class GoggleOverlayRenderer {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) {
|
||||||
|
if (event.getType() != ElementType.HOTBAR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
|
||||||
|
if (!(objectMouseOver instanceof BlockRayTraceResult))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver;
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
ClientWorld world = mc.world;
|
||||||
|
BlockPos pos = result.getPos();
|
||||||
|
ItemStack goggles = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD);
|
||||||
|
TileEntity te = world.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (!AllItems.GOGGLES.typeOf(goggles))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(te instanceof IHaveGoggleInformation))
|
||||||
|
return;
|
||||||
|
|
||||||
|
IHaveGoggleInformation gte = (IHaveGoggleInformation) te;
|
||||||
|
|
||||||
|
List<String> tooltip = new ArrayList<>();
|
||||||
|
|
||||||
|
if (!gte.addToGoggleTooltip(tooltip, mc.player.isSneaking()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
Screen tooltipScreen = new Screen(null) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Minecraft mc, int width, int height) {
|
||||||
|
this.minecraft = mc;
|
||||||
|
this.itemRenderer = mc.getItemRenderer();
|
||||||
|
this.font = mc.fontRenderer;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
tooltipScreen.init(mc, mc.mainWindow.getScaledWidth(), mc.mainWindow.getScaledHeight());
|
||||||
|
tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
||||||
|
ItemStack item = goggles;
|
||||||
|
ScreenElementRenderer.render3DItem(() -> {
|
||||||
|
GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0);
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.simibubi.create.modules.contraptions.goggle;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implement this Interface in the TileEntity class that wants to add info to the screen
|
||||||
|
* */
|
||||||
|
public interface IHaveGoggleInformation {
|
||||||
|
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||||
|
String spacing = " ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method will be called when looking at a TileEntity that implemented this interface
|
||||||
|
*
|
||||||
|
* @return {{@code true}} if the tooltip creation was successful and should be displayed,
|
||||||
|
* or {{@code false}} if the overlay should not be displayed
|
||||||
|
* */
|
||||||
|
default boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String format(double d) {
|
||||||
|
return decimalFormat.format(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,10 +7,14 @@ import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
|
||||||
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
|
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class AnalogLeverTileEntity extends SmartTileEntity {
|
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation {
|
||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
int lastChange;
|
int lastChange;
|
||||||
|
@ -69,6 +73,13 @@ public class AnalogLeverTileEntity extends SmartTileEntity {
|
||||||
sendData();
|
sendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
tooltip.add(spacing + Lang.translate("tooltip.analogStrength", this.state));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public int getState() {
|
public int getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,274 +0,0 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.gauge;
|
|
||||||
|
|
||||||
import static net.minecraft.util.text.TextFormatting.AQUA;
|
|
||||||
import static net.minecraft.util.text.TextFormatting.DARK_GRAY;
|
|
||||||
import static net.minecraft.util.text.TextFormatting.GRAY;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.simibubi.create.AllBlocks;
|
|
||||||
import com.simibubi.create.AllItems;
|
|
||||||
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
|
|
||||||
import com.simibubi.create.foundation.item.ItemDescription;
|
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
|
||||||
import com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity;
|
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact;
|
|
||||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
|
||||||
|
|
||||||
import com.simibubi.create.modules.contraptions.redstone.AnalogLeverTileEntity;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
||||||
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
|
||||||
public class GaugeInformationRenderer {
|
|
||||||
|
|
||||||
private static DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
|
||||||
private static String spacing = " ";
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) {
|
|
||||||
if (event.getType() != ElementType.HOTBAR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
|
|
||||||
if (!(objectMouseOver instanceof BlockRayTraceResult))
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockRayTraceResult result = (BlockRayTraceResult) objectMouseOver;
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
ClientWorld world = mc.world;
|
|
||||||
BlockPos pos = result.getPos();
|
|
||||||
BlockState state = world.getBlockState(pos);
|
|
||||||
ItemStack goggles = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD);
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
|
||||||
boolean notFastEnough = (te instanceof KineticTileEntity)
|
|
||||||
&& !((KineticTileEntity) te).isSpeedRequirementFulfilled() && ((KineticTileEntity) te).getSpeed() != 0;
|
|
||||||
|
|
||||||
if (!AllItems.GOGGLES.typeOf(goggles) && !notFastEnough)
|
|
||||||
return;
|
|
||||||
if (mc.player.isSneaking() && !(te instanceof AnalogLeverTileEntity))
|
|
||||||
return;
|
|
||||||
|
|
||||||
List<String> tooltip = new ArrayList<>();
|
|
||||||
|
|
||||||
if (notFastEnough) {
|
|
||||||
addSpeedRequirementMessage(state, tooltip, (KineticTileEntity) te);
|
|
||||||
goggles = AllItems.GOGGLES.asStack();
|
|
||||||
} else if (state.getBlock() instanceof GaugeBlock)
|
|
||||||
addGaugeTooltip(state, tooltip, te);
|
|
||||||
else {
|
|
||||||
if (te instanceof GeneratingKineticTileEntity)
|
|
||||||
addGeneratorTooltip(state, tooltip, (GeneratingKineticTileEntity) te);
|
|
||||||
if (te instanceof KineticTileEntity)
|
|
||||||
addStressTooltip(state, tooltip, (KineticTileEntity) te);
|
|
||||||
if (te instanceof AnalogLeverTileEntity)
|
|
||||||
addLeverTooltip(state, tooltip, (AnalogLeverTileEntity) te);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tooltip.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
Screen tooltipScreen = new Screen(null) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Minecraft mc, int width, int height) {
|
|
||||||
this.minecraft = mc;
|
|
||||||
this.itemRenderer = mc.getItemRenderer();
|
|
||||||
this.font = mc.fontRenderer;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
tooltipScreen.init(mc, mc.mainWindow.getScaledWidth(), mc.mainWindow.getScaledHeight());
|
|
||||||
tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2);
|
|
||||||
ItemStack item = goggles;
|
|
||||||
ScreenElementRenderer.render3DItem(() -> {
|
|
||||||
GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0);
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addSpeedRequirementMessage(BlockState state, List<String> tooltip, KineticTileEntity te) {
|
|
||||||
String spacing = " ";
|
|
||||||
tooltip.addAll(TooltipHelper.cutString(spacing
|
|
||||||
+ Lang.translate("gui.contraptions.not_fast_enough", I18n.format(state.getBlock().getTranslationKey())),
|
|
||||||
GRAY, TextFormatting.WHITE));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addStressTooltip(BlockState state, List<String> tooltip, KineticTileEntity te) {
|
|
||||||
float stressApplied = te.getStressApplied();
|
|
||||||
if (stressApplied == 0 || !StressImpact.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
String _kineticStatsTitle = Lang.translate("gui.goggles.kinetic_stats");
|
|
||||||
String _stressImpact = Lang.translate("tooltip.stressImpact");
|
|
||||||
String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed");
|
|
||||||
String _stressUnit = Lang.translate("generic.unit.stress");
|
|
||||||
String _baseValue = Lang.translate("gui.goggles.base_value");
|
|
||||||
|
|
||||||
tooltip.add(spacing + _kineticStatsTitle);
|
|
||||||
tooltip.add(spacing + GRAY + _stressImpact);
|
|
||||||
|
|
||||||
String addedStress = AQUA + "" + format(stressApplied) + _stressUnit + " " + DARK_GRAY + _baseValue;
|
|
||||||
String addedStressAtBase =
|
|
||||||
GRAY + "" + format(stressApplied * Math.abs(te.getSpeed())) + _stressUnit + " " + DARK_GRAY + _atCurrentSpeed;
|
|
||||||
tooltip.add(spacing + " " + addedStress);
|
|
||||||
tooltip.add(spacing + " " + addedStressAtBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addGeneratorTooltip(BlockState state, List<String> tooltip, GeneratingKineticTileEntity te) {
|
|
||||||
float addedStressCapacity = te.getAddedStressCapacity();
|
|
||||||
if (addedStressCapacity == 0 || !StressImpact.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
String _stressUnit = Lang.translate("generic.unit.stress");
|
|
||||||
String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed");
|
|
||||||
String _baseValue = Lang.translate("gui.goggles.base_value");
|
|
||||||
String _generatorStatsTitle = Lang.translate("gui.goggles.generator_stats");
|
|
||||||
String _capacityProvided = Lang.translate("tooltip.capacityProvided");
|
|
||||||
|
|
||||||
float speed = te.getTheoreticalSpeed();
|
|
||||||
if (speed != te.getGeneratedSpeed() && speed != 0)
|
|
||||||
addedStressCapacity *= (te.getGeneratedSpeed() / speed);
|
|
||||||
|
|
||||||
tooltip.add(spacing + _generatorStatsTitle);
|
|
||||||
tooltip.add(spacing + GRAY + _capacityProvided);
|
|
||||||
|
|
||||||
float actualSpeed = Math.abs(speed);
|
|
||||||
float relativeCap = 0;
|
|
||||||
if (actualSpeed != 0)
|
|
||||||
relativeCap = addedStressCapacity * actualSpeed;
|
|
||||||
|
|
||||||
String addedCapacity =
|
|
||||||
AQUA + "" + format(addedStressCapacity) + _stressUnit + " " + DARK_GRAY + _baseValue;
|
|
||||||
String addedCapacityAtBase = GRAY + "" + format(relativeCap) + _stressUnit + " " + DARK_GRAY + _atCurrentSpeed;
|
|
||||||
tooltip.add(spacing + " " + addedCapacity);
|
|
||||||
tooltip.add(spacing + " " + addedCapacityAtBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addGaugeTooltip(BlockState state, List<String> tooltip, TileEntity te) {
|
|
||||||
|
|
||||||
String _rpmUnit = Lang.translate("generic.unit.rpm");
|
|
||||||
String _speedGaugeTitle = Lang.translate("gui.speed_gauge.title");
|
|
||||||
String _infoHeader = Lang.translate("gui.gauge.info_header");
|
|
||||||
String _overStressed = Lang.translate("gui.stress_gauge.overstressed");
|
|
||||||
String _noRotation = Lang.translate("gui.stress_gauge.no_rotation");
|
|
||||||
String _capacity = Lang.translate("gui.stress_gauge.capacity");
|
|
||||||
String _stressGaugeTitle = Lang.translate("gui.stress_gauge.title");
|
|
||||||
String _stressUnit = Lang.translate("generic.unit.stress");
|
|
||||||
String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed");
|
|
||||||
String _baseValue = Lang.translate("gui.goggles.base_value");
|
|
||||||
|
|
||||||
tooltip.add(spacing + _infoHeader);
|
|
||||||
|
|
||||||
if (AllBlocks.STRESS_GAUGE.typeOf(state)) {
|
|
||||||
if (!(te instanceof StressGaugeTileEntity))
|
|
||||||
return;
|
|
||||||
if (!StressImpact.isEnabled()) {
|
|
||||||
tooltip.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
StressGaugeTileEntity stressGauge = (StressGaugeTileEntity) te;
|
|
||||||
List<String> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high");
|
|
||||||
double stress = stressGauge.getNetworkStress();
|
|
||||||
double cap = stressGauge.getNetworkCapacity();
|
|
||||||
double relStress = stress / (cap == 0 ? 1 : cap);
|
|
||||||
StressImpact impactId = relStress > 1 ? null
|
|
||||||
: (relStress > .75f) ? StressImpact.HIGH
|
|
||||||
: (relStress > .5f ? StressImpact.MEDIUM : StressImpact.LOW);
|
|
||||||
|
|
||||||
TextFormatting color = TextFormatting.RED;
|
|
||||||
if (impactId == StressImpact.LOW)
|
|
||||||
color = TextFormatting.GREEN;
|
|
||||||
if (impactId == StressImpact.MEDIUM)
|
|
||||||
color = TextFormatting.YELLOW;
|
|
||||||
if (impactId == StressImpact.HIGH)
|
|
||||||
color = TextFormatting.GOLD;
|
|
||||||
|
|
||||||
String level = TextFormatting.DARK_RED + ItemDescription.makeProgressBar(3, 2) + "" + _overStressed;
|
|
||||||
if (impactId != null) {
|
|
||||||
int index = impactId.ordinal();
|
|
||||||
level = color + ItemDescription.makeProgressBar(3, index) + stressLevels.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
level += " (" + (int) (relStress * 100) + "%)";
|
|
||||||
|
|
||||||
float theoreticalSpeed = stressGauge.getTheoreticalSpeed();
|
|
||||||
if (theoreticalSpeed == 0)
|
|
||||||
level = DARK_GRAY + ItemDescription.makeProgressBar(3, -1) + _noRotation;
|
|
||||||
|
|
||||||
tooltip.add(spacing + GRAY + _stressGaugeTitle);
|
|
||||||
tooltip.add(spacing + level);
|
|
||||||
|
|
||||||
if (theoreticalSpeed != 0) {
|
|
||||||
tooltip.add(spacing + GRAY + _capacity);
|
|
||||||
|
|
||||||
String capacity = color + "" + format((cap - stress) / Math.abs(theoreticalSpeed)) + _stressUnit + " "
|
|
||||||
+ DARK_GRAY + _baseValue;
|
|
||||||
String capacityAtBase = GRAY + "" + format(cap - stress) + _stressUnit + " " + DARK_GRAY + _atCurrentSpeed;
|
|
||||||
tooltip.add(spacing + " " + capacity);
|
|
||||||
tooltip.add(spacing + " " + capacityAtBase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AllBlocks.SPEED_GAUGE.typeOf(state)) {
|
|
||||||
if (!(te instanceof SpeedGaugeTileEntity))
|
|
||||||
return;
|
|
||||||
SpeedGaugeTileEntity speedGauge = (SpeedGaugeTileEntity) te;
|
|
||||||
float speed = speedGauge.getTheoreticalSpeed();
|
|
||||||
boolean overstressed = speedGauge.getSpeed() == 0 && speed != 0;
|
|
||||||
|
|
||||||
SpeedLevel speedLevel = SpeedLevel.of(speed);
|
|
||||||
String color = speedLevel.getTextColor() + "";
|
|
||||||
if (overstressed)
|
|
||||||
color = DARK_GRAY + "" + TextFormatting.STRIKETHROUGH;
|
|
||||||
|
|
||||||
List<String> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high");
|
|
||||||
int index = speedLevel.ordinal();
|
|
||||||
String level = color + ItemDescription.makeProgressBar(3, index)
|
|
||||||
+ (speedLevel != SpeedLevel.NONE ? speedLevels.get(index) : "");
|
|
||||||
level += " (" + format(Math.abs(speed)) + "" + _rpmUnit + ") ";
|
|
||||||
|
|
||||||
tooltip.add(spacing + GRAY + _speedGaugeTitle);
|
|
||||||
tooltip.add(spacing + level);
|
|
||||||
|
|
||||||
if (overstressed)
|
|
||||||
tooltip.add(spacing + TextFormatting.DARK_RED + _overStressed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addLeverTooltip(BlockState state, List<String> tooltip, AnalogLeverTileEntity te) {
|
|
||||||
int leverState = te.getState();
|
|
||||||
tooltip.add(spacing + Lang.translate("tooltip.analogStrength", leverState));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String format(double d) {
|
|
||||||
return decimalFormat.format(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +1,17 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.gauge;
|
package com.simibubi.create.modules.contraptions.relays.gauge;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
|
||||||
public class GaugeTileEntity extends KineticTileEntity {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInformation {
|
||||||
|
|
||||||
public float dialTarget;
|
public float dialTarget;
|
||||||
public float dialState;
|
public float dialState;
|
||||||
|
@ -39,4 +45,11 @@ public class GaugeTileEntity extends KineticTileEntity {
|
||||||
dialState -= (dialState - 1) * world.rand.nextFloat();
|
dialState -= (dialState - 1) * world.rand.nextFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
tooltip.add(spacing + Lang.translate("gui.gauge.info_header"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,16 @@ import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.config.AllConfigs;
|
import com.simibubi.create.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.GogglesItem;
|
import com.simibubi.create.modules.contraptions.GogglesItem;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel;
|
||||||
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SpeedGaugeTileEntity extends GaugeTileEntity{
|
||||||
|
|
||||||
public SpeedGaugeTileEntity() {
|
public SpeedGaugeTileEntity() {
|
||||||
super(AllTileEntities.SPEED_GAUGE.type);
|
super(AllTileEntities.SPEED_GAUGE.type);
|
||||||
|
@ -41,4 +45,15 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
super.addToGoggleTooltip(tooltip, isPlayerSneaking);
|
||||||
|
|
||||||
|
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.speed_gauge.title"));
|
||||||
|
tooltip.add(spacing + SpeedLevel.getFormattedSpeedText(speed, overStressed));
|
||||||
|
if (overStressed)
|
||||||
|
tooltip.add(spacing + TextFormatting.DARK_RED + Lang.translate("gui.stress_gauge.overstressed"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.gauge;
|
package com.simibubi.create.modules.contraptions.relays.gauge;
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
|
import com.simibubi.create.foundation.item.ItemDescription;
|
||||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact;
|
import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact;
|
||||||
|
import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class StressGaugeTileEntity extends GaugeTileEntity {
|
public class StressGaugeTileEntity extends GaugeTileEntity {
|
||||||
|
|
||||||
|
@ -47,6 +53,38 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
||||||
updateStressFromNetwork(capacity, stress);
|
updateStressFromNetwork(capacity, stress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||||
|
if (!StressImpact.isEnabled())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
super.addToGoggleTooltip(tooltip, isPlayerSneaking);
|
||||||
|
|
||||||
|
double capacity = getNetworkCapacity();
|
||||||
|
double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity);
|
||||||
|
|
||||||
|
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.stress_gauge.title"));
|
||||||
|
|
||||||
|
if (getTheoreticalSpeed() == 0)
|
||||||
|
tooltip.add(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) + Lang.translate("gui.stress_gauge.no_rotation"));
|
||||||
|
else {
|
||||||
|
tooltip.add(spacing + StressImpact.getFormattedStressText(stressFraction));
|
||||||
|
|
||||||
|
tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("gui.stress_gauge.capacity"));
|
||||||
|
|
||||||
|
double remainingCapacity = capacity - getNetworkStress();
|
||||||
|
double remainingCapacityAtBase = remainingCapacity / Math.abs(getTheoreticalSpeed());
|
||||||
|
|
||||||
|
String capacityString = spacing + StressImpact.of(stressFraction).getRelativeColor() + "%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s";
|
||||||
|
|
||||||
|
tooltip.add(String.format(capacityString, IHaveGoggleInformation.format(remainingCapacityAtBase), Lang.translate("gui.goggles.base_value")));
|
||||||
|
tooltip.add(String.format(capacityString, IHaveGoggleInformation.format(remainingCapacity), Lang.translate("gui.goggles.at_current_speed")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public float getNetworkStress() {
|
public float getNetworkStress() {
|
||||||
return stress;
|
return stress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,6 +601,7 @@
|
||||||
"create.tooltip.stressImpact.low": "Low",
|
"create.tooltip.stressImpact.low": "Low",
|
||||||
"create.tooltip.stressImpact.medium": "Moderate",
|
"create.tooltip.stressImpact.medium": "Moderate",
|
||||||
"create.tooltip.stressImpact.high": "High",
|
"create.tooltip.stressImpact.high": "High",
|
||||||
|
"create.tooltip.stressImpact.overstressed": "Overstressed",
|
||||||
|
|
||||||
"create.tooltip.capacityProvided": "Stress Capacity: %1$s",
|
"create.tooltip.capacityProvided": "Stress Capacity: %1$s",
|
||||||
"create.tooltip.capacityProvided.low": "Small",
|
"create.tooltip.capacityProvided.low": "Small",
|
||||||
|
|
Loading…
Reference in a new issue