mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 17:44:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80e761d83f | ||
|
|
ef0f8b5329 | ||
|
|
65e4a773d0 | ||
|
|
30717912fb | ||
|
|
1421b83a5b | ||
|
|
2de1ec4235 |
No files matched your search
+6
-6
@@ -12,13 +12,13 @@ dependencies {
|
||||
}
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderCore:0.5.12:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:BuildCraft:7.1.57:dev")
|
||||
runtimeOnlyNonPublishable("curse.maven:cofh-lib-220333:2388748")
|
||||
runtimeOnlyNonPublishable("curse.maven:extrautils-225561:2264383")
|
||||
runtimeOnlyNonPublishable(deobfCurse("cofh-lib-220333:2388748"))
|
||||
runtimeOnlyNonPublishable(deobfCurse("extrautils-225561:2264383"))
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:OpenBlocks:1.12.12-GTNH:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Railcraft:9.17.26:dev")
|
||||
runtimeOnlyNonPublishable('curse.maven:thermal-foundation-222880:2388753')
|
||||
runtimeOnlyNonPublishable('curse.maven:thermal-expansion-69163:2388759')
|
||||
runtimeOnlyNonPublishable('curse.maven:thermal-dynamics-227443:2388756')
|
||||
implementation('curse.maven:cofh-core-69162:2388751')
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-foundation-222880:2388753'))
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-expansion-69163:2388759'))
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-dynamics-227443:2388756'))
|
||||
implementation(deobfCurse('cofh-core-69162:2388751'))
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
|
||||
}
|
||||
@@ -40,7 +40,8 @@ import mcp.mobius.waila.utils.ModIdentification;
|
||||
name = "Waila",
|
||||
version = Tags.GRADLETOKEN_VERSION,
|
||||
dependencies = "after:NotEnoughItems@[1.0.4.0,)",
|
||||
acceptableRemoteVersions = "*")
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "mcp.mobius.waila.client.WailaGuiFactory")
|
||||
public class Waila {
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
|
||||
@@ -12,18 +12,18 @@ import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
String id;
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
TileEntity entity;
|
||||
NBTTagCompound partialNBT = null;
|
||||
NBTTagCompound remoteNBT = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
public static final DataAccessorFMP instance = new DataAccessorFMP();
|
||||
|
||||
public static DataAccessorFMP instance = new DataAccessorFMP();
|
||||
private String id;
|
||||
private World world;
|
||||
private EntityPlayer player;
|
||||
private MovingObjectPosition mop;
|
||||
private Vec3 renderingvec;
|
||||
private TileEntity tileEntity;
|
||||
private NBTTagCompound partialNBT;
|
||||
private double partialFrame;
|
||||
|
||||
private DataAccessorFMP() {}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT,
|
||||
String id) {
|
||||
@@ -35,13 +35,24 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.partialNBT = _partialNBT;
|
||||
this.id = id;
|
||||
this.renderingvec = renderVec;
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
id = null;
|
||||
world = null;
|
||||
player = null;
|
||||
mop = null;
|
||||
renderingvec = null;
|
||||
tileEntity = null;
|
||||
partialNBT = null;
|
||||
partialFrame = 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
@@ -54,7 +65,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.entity;
|
||||
return this.tileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,12 +80,9 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getFullNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNBT)) return this.remoteNBT;
|
||||
|
||||
if (this.tileEntity == null) return null;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -98,20 +106,4 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag) {
|
||||
if (tag == null) {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
|
||||
public class WailaGuiFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return ScreenConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,20 @@ public class LabelFixedFont extends WidgetBase {
|
||||
|
||||
protected String text = "";
|
||||
protected int color;
|
||||
protected boolean shadow;
|
||||
|
||||
public LabelFixedFont(IWidget parent, String text) {
|
||||
super(parent);
|
||||
this.setText(text);
|
||||
this.color = 0xFFFFFF;
|
||||
this.shadow = false;
|
||||
}
|
||||
|
||||
public LabelFixedFont(IWidget parent, String text, int color) {
|
||||
super(parent);
|
||||
this.setText(text);
|
||||
this.color = color;
|
||||
this.shadow = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,6 +42,10 @@ public class LabelFixedFont extends WidgetBase {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setShadow(boolean shadow) {
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
private void updateGeometry() {
|
||||
if (this.geom == null) this.geom = new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY);
|
||||
|
||||
@@ -56,7 +63,8 @@ public class LabelFixedFont extends WidgetBase {
|
||||
@Override
|
||||
public void draw(Point pos) {
|
||||
this.saveGLState();
|
||||
this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
|
||||
if (this.shadow) this.mc.fontRenderer.drawStringWithShadow(this.text, pos.getX(), pos.getY(), this.color);
|
||||
else this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,17 @@ import mcp.mobius.waila.gui.widgets.WidgetBase;
|
||||
|
||||
public abstract class ButtonBase extends WidgetBase {
|
||||
|
||||
protected static final int BUTTON_TEX_U = 0;
|
||||
protected static final int BUTTON_TEX_V_BASE = 66;
|
||||
protected static final int BUTTON_TEX_V_STEP = 20;
|
||||
protected static final int BUTTON_TEX_W = 200;
|
||||
protected static final int BUTTON_TEX_H = 20;
|
||||
protected static final int BUTTON_BORDER = 2;
|
||||
protected static final int COLOR_TEXT = 0xffffff;
|
||||
protected static final int COLOR_TEXT_HOVER = 0xffffa0;
|
||||
|
||||
protected boolean mouseOver = false;
|
||||
protected static ResourceLocation widgetsTexture = new ResourceLocation("textures/gui/widgets.png");
|
||||
protected static final ResourceLocation widgetsTexture = new ResourceLocation("textures/gui/widgets.png");
|
||||
|
||||
public ButtonBase(IWidget parent) {
|
||||
super(parent);
|
||||
@@ -25,10 +34,14 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int textColor = this.mouseOver ? COLOR_TEXT_HOVER : COLOR_TEXT;
|
||||
|
||||
for (IWidget widget : this.widgets.values())
|
||||
if (widget instanceof LabelFixedFont) if (this.mouseOver) ((LabelFixedFont) widget).setColor(0xffffa0);
|
||||
else((LabelFixedFont) widget).setColor(0xffffff);
|
||||
for (IWidget widget : this.widgets.values()) {
|
||||
if (!(widget instanceof LabelFixedFont)) continue;
|
||||
LabelFixedFont label = (LabelFixedFont) widget;
|
||||
label.setShadow(true);
|
||||
label.setColor(textColor);
|
||||
}
|
||||
|
||||
super.draw();
|
||||
}
|
||||
@@ -40,20 +53,108 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
|
||||
if (this.mouseOver) texOffset = 1;
|
||||
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
this.drawVanillaButton(texOffset);
|
||||
|
||||
this.loadGLState();
|
||||
}
|
||||
|
||||
protected void drawVanillaButton(int texOffset) {
|
||||
int x = this.getPos().getX();
|
||||
int y = this.getPos().getY();
|
||||
int width = this.getSize().getX();
|
||||
int height = this.getSize().getY();
|
||||
int v = BUTTON_TEX_V_BASE + texOffset * BUTTON_TEX_V_STEP;
|
||||
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
if (width <= 0 || height <= 0) return;
|
||||
|
||||
int borderX = Math.min(BUTTON_BORDER, width / 2);
|
||||
int borderY = Math.min(BUTTON_BORDER, height / 2);
|
||||
int midW = width - borderX * 2;
|
||||
int midH = height - borderY * 2;
|
||||
int srcMidW = BUTTON_TEX_W - BUTTON_BORDER * 2;
|
||||
int srcMidH = BUTTON_TEX_H - BUTTON_BORDER * 2;
|
||||
|
||||
// Corners
|
||||
UIHelper.drawTexture(x, y, borderX, borderY, BUTTON_TEX_U, v, BUTTON_BORDER, BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x,
|
||||
y + height - borderY,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_U,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y + height - borderY,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
|
||||
if (midW > 0) {
|
||||
// Top + bottom edges
|
||||
UIHelper.drawTexture(x + borderX, y, midW, borderY, BUTTON_BORDER, v, srcMidW, BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + borderX,
|
||||
y + height - borderY,
|
||||
midW,
|
||||
borderY,
|
||||
BUTTON_BORDER,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
srcMidW,
|
||||
BUTTON_BORDER);
|
||||
}
|
||||
|
||||
if (midH > 0) {
|
||||
// Left + right edges
|
||||
UIHelper.drawTexture(
|
||||
x,
|
||||
y + borderY,
|
||||
borderX,
|
||||
midH,
|
||||
BUTTON_TEX_U,
|
||||
v + BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
srcMidH);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y + borderY,
|
||||
borderX,
|
||||
midH,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v + BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
srcMidH);
|
||||
}
|
||||
|
||||
if (midW > 0 && midH > 0) {
|
||||
// Center
|
||||
UIHelper.drawTexture(
|
||||
x + borderX,
|
||||
y + borderY,
|
||||
midW,
|
||||
midH,
|
||||
BUTTON_BORDER,
|
||||
v + BUTTON_BORDER,
|
||||
srcMidW,
|
||||
srcMidH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseEnter(MouseEvent event) {
|
||||
mouseOver = true;
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.lwjgl.util.Point;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
|
||||
public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
@@ -47,17 +46,7 @@ public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
if (!ConfigHandler.instance().forcedConfigs.containsKey(this.configKey)) super.draw(pos);
|
||||
else {
|
||||
this.saveGLState();
|
||||
int texOffset = -1;
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
this.drawVanillaButton(-1);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.lwjgl.util.Point;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
|
||||
public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
@@ -41,17 +40,7 @@ public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
super.draw(pos);
|
||||
else {
|
||||
this.saveGLState();
|
||||
int texOffset = -1;
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
this.drawVanillaButton(-1);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,13 @@ public class DecoratorFMP implements IWailaBlockDecorator {
|
||||
accessor.getRenderingPosition(),
|
||||
accessor.getPartialFrame());
|
||||
|
||||
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id).values())
|
||||
for (IWailaFMPDecorator provider : providersList)
|
||||
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id)
|
||||
.values()) {
|
||||
for (IWailaFMPDecorator provider : providersList) {
|
||||
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getHeadFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +66,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getBodyFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +91,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getTailFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,20 +90,20 @@ public enum WailaPacketHandler {
|
||||
}
|
||||
|
||||
public void writeNBT(ByteBuf target, NBTTagCompound tag) throws IOException {
|
||||
if (tag == null) target.writeShort(-1);
|
||||
if (tag == null) target.writeInt(-1);
|
||||
else {
|
||||
byte[] abyte = CompressedStreamTools.compress(tag);
|
||||
target.writeShort((short) abyte.length);
|
||||
target.writeInt(abyte.length);
|
||||
target.writeBytes(abyte);
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound readNBT(ByteBuf dat) throws IOException {
|
||||
short short1 = dat.readShort();
|
||||
int val = dat.readInt();
|
||||
|
||||
if (short1 < 0) return null;
|
||||
if (val < 0) return null;
|
||||
else {
|
||||
byte[] abyte = new byte[short1];
|
||||
byte[] abyte = new byte[val];
|
||||
dat.readBytes(abyte);
|
||||
return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
|
||||
tessellator.startDrawingQuads();
|
||||
// Intentionally draw 2 pixels taller than needed than cover with the border to make the texture more
|
||||
// visible
|
||||
int i = (int) ((double) (maxStringW - 2) * amount / capacity);
|
||||
int i = (int) ((double) (maxStringW - 2) * (amount / Math.max(capacity, amount)));
|
||||
int j = 0;
|
||||
for (; i > height; i = i - height) {
|
||||
drawRectFromIcon(tessellator, 1 + (j * height), 0, 0, icon, height, height);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
|
||||
drawRect(tessellator, 1 + i, 0, 0, width, height, 0.0, 0.0, 0.5, 1.0);
|
||||
}
|
||||
|
||||
double i = (double) (maxStringW - 2) * amount / capacity;
|
||||
double i = (double) (maxStringW - 2) * ((double) amount / Math.max(capacity, amount));
|
||||
int drawnRects = 0;
|
||||
for (; i > width; i -= width) {
|
||||
drawRect(tessellator, 1 + (drawnRects * width), 0, 0, width, height, 0.5, 0.0, 1.0, 1.0);
|
||||
|
||||
Reference in new issue
Block a user