1.16 port

This commit is contained in:
yueh
2020-07-22 16:44:42 +02:00
parent 662dbca3e1
commit 56ecda5173
225 changed files with 1214 additions and 969 deletions
@@ -18,6 +18,7 @@
package appeng.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -26,6 +27,7 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.text.StringTextComponent;
/**
* A modified version of the Minecraft text field. You can initialize it over
@@ -52,10 +54,11 @@ public class AETextField extends TextFieldWidget {
*/
public AETextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth('_'),
height - 2 * PADDING, "");
super(fontRenderer, xPos + PADDING, yPos + PADDING,
width - 2 * PADDING - (int) fontRenderer.getStringWidth("_"), height - 2 * PADDING,
new StringTextComponent(""));
this._fontPad = (int) fontRenderer.getCharWidth('_');
this._fontPad = (int) fontRenderer.getStringWidth("_");
}
public void selectAll() {
@@ -68,16 +71,18 @@ public class AETextField extends TextFieldWidget {
}
@Override
public void renderButton(int mouseX, int mouseY, float partial) {
public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partial) {
if (this.getVisible()) {
if (this.isFocused()) {
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
this.y + this.height + PADDING - 1, 0xFF606060);
fill(matrixStack, this.x - PADDING + 1, this.y - PADDING + 1,
this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFF606060);
} else {
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
this.y + this.height + PADDING - 1, 0xFFA8A8A8);
fill(matrixStack, this.x - PADDING + 1, this.y - PADDING + 1,
this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFFA8A8A8);
}
super.renderButton(mouseX, mouseY, partial);
super.renderButton(matrixStack, mouseX, mouseY, partial);
}
}
@@ -1,10 +1,13 @@
package appeng.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
private final int x;
@@ -28,13 +31,13 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
public void slotClicked(final ItemStack clickStack, final int mouseButton) {
}
public abstract void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks);
public abstract void drawContent(MatrixStack matrixStack, final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks);
public void drawBackground(int guileft, int guitop, int currentZIndex) {
}
@Override
public String getMessage() {
public ITextComponent getMessage() {
return null;
}
@@ -18,6 +18,8 @@
package appeng.client.gui.widgets;
import net.minecraft.util.text.ITextComponent;
/**
* AEBaseGui controlled Tooltip Interface.
*/
@@ -28,7 +30,7 @@ public interface ITooltip {
*
* @return tooltip message
*/
String getMessage();
ITextComponent getMessage();
/**
* x Location for the object that triggers the tooltip.
@@ -18,12 +18,14 @@
package appeng.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
public abstract class IconButton extends Button implements ITooltip {
@@ -33,7 +35,7 @@ public abstract class IconButton extends Button implements ITooltip {
private boolean halfSize = false;
public IconButton(final int x, final int y, IPressable onPress) {
super(x, y, 16, 16, "", onPress);
super(x, y, 16, 16, new StringTextComponent(""), onPress);
}
public void setVisibility(final boolean vis) {
@@ -42,7 +44,7 @@ public abstract class IconButton extends Button implements ITooltip {
}
@Override
public void renderButton(final int mouseX, final int mouseY, float partial) {
public void renderButton(MatrixStack matrixStack, final int mouseX, final int mouseY, float partial) {
Minecraft minecraft = Minecraft.getInstance();
@@ -22,6 +22,7 @@ import java.util.function.LongConsumer;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.util.text.StringTextComponent;
public class NumberBox extends TextFieldWidget {
@@ -35,7 +36,7 @@ public class NumberBox extends TextFieldWidget {
public NumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height,
final Class<?> type, LongConsumer changeListener) {
super(fontRenderer, x, y, width, height, "0");
super(fontRenderer, x, y, width, height, new StringTextComponent("0"));
this.setText("0");
setResponder(this::handleTextChanged);
this.lastValue = 0;
@@ -18,9 +18,13 @@
package appeng.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.container.interfaces.IProgressProvider;
@@ -33,8 +37,8 @@ public class ProgressBar extends Widget implements ITooltip {
private final int fill_u;
private final int fill_v;
private final Direction layout;
private final String titleName;
private String fullMsg;
private final ITextComponent titleName;
private ITextComponent fullMsg;
public ProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
final int u, final int y, final int width, final int height, final Direction dir) {
@@ -42,8 +46,9 @@ public class ProgressBar extends Widget implements ITooltip {
}
public ProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
final int u, final int y, final int width, final int height, final Direction dir, final String title) {
super(posX, posY, width, height, "");
final int u, final int y, final int width, final int height, final Direction dir,
final ITextComponent title) {
super(posX, posY, width, height, new StringTextComponent(""));
this.source = source;
this.texture = new ResourceLocation("appliedenergistics2", "textures/" + texture);
this.fill_u = u;
@@ -53,7 +58,7 @@ public class ProgressBar extends Widget implements ITooltip {
}
@Override
public void renderButton(final int par2, final int par3, final float partial) {
public void renderButton(MatrixStack matrixStack, final int par2, final int par3, final float partial) {
if (this.visible) {
Minecraft.getInstance().getTextureManager().bindTexture(this.texture);
final int max = this.source.getMaxProgress();
@@ -71,18 +76,20 @@ public class ProgressBar extends Widget implements ITooltip {
}
}
public void setFullMsg(final String msg) {
public void setFullMsg(final ITextComponent msg) {
this.fullMsg = msg;
}
@Override
public String getMessage() {
public ITextComponent getMessage() {
if (this.fullMsg != null) {
return this.fullMsg;
}
ITextComponent result = this.titleName != null ? this.titleName : new StringTextComponent("");
return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' '
+ GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
return result.deepCopy().func_240702_b_("\n").func_240702_b_(this.source.getCurrentProgress() + " ")
.func_230529_a_(
GuiText.Of.textComponent().deepCopy().func_240702_b_(" " + this.source.getMaxProgress()));
}
@Override
@@ -18,6 +18,7 @@
package appeng.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
@@ -26,6 +27,7 @@ import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
public class TabButton extends Button implements ITooltip {
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
@@ -35,7 +37,7 @@ public class TabButton extends Button implements ITooltip {
private int myIcon = -1;
private ItemStack myItem;
public TabButton(final int x, final int y, final int ico, final String message, final ItemRenderer ir,
public TabButton(final int x, final int y, final int ico, final ITextComponent message, final ItemRenderer ir,
IPressable onPress) {
super(x, y, 22, 22, message, onPress);
@@ -52,7 +54,7 @@ public class TabButton extends Button implements ITooltip {
* @param message mouse over message
* @param ir renderer
*/
public TabButton(final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir,
public TabButton(final int x, final int y, final ItemStack ico, final ITextComponent message, final ItemRenderer ir,
IPressable onPress) {
super(x, y, 22, 22, message, onPress);
this.myItem = ico;
@@ -60,7 +62,7 @@ public class TabButton extends Button implements ITooltip {
}
@Override
public void renderButton(final int x, final int y, float partial) {
public void renderButton(MatrixStack matrixStack, final int x, final int y, float partial) {
final Minecraft minecraft = Minecraft.getInstance();
if (this.visible) {
@@ -73,13 +75,13 @@ public class TabButton extends Button implements ITooltip {
final int offsetX = this.hideEdge > 0 ? 1 : 0;
blit(this.x, this.y, uv_x * 16, 0, 25, 22);
blit(matrixStack, this.x, this.y, uv_x * 16, 0, 25, 22);
if (this.myIcon >= 0) {
final int uv_y = this.myIcon / 16;
uv_x = this.myIcon - uv_y * 16;
blit(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
blit(matrixStack, offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
}
RenderSystem.disableAlphaTest();
@@ -20,12 +20,15 @@ package appeng.client.gui.widgets;
import java.util.regex.Pattern;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class ToggleButton extends Button implements ITooltip {
@@ -42,7 +45,7 @@ public class ToggleButton extends Button implements ITooltip {
public ToggleButton(final int x, final int y, final int on, final int off, final String displayName,
final String displayHint, IPressable onPress) {
super(x, y, 16, 16, "", onPress);
super(x, y, 16, 16, new StringTextComponent(""), onPress);
this.iconIdxOn = on;
this.iconIdxOff = off;
this.displayName = displayName;
@@ -54,7 +57,7 @@ public class ToggleButton extends Button implements ITooltip {
}
@Override
public void renderButton(final int mouseX, final int mouseY, final float partial) {
public void renderButton(MatrixStack matrixStack, final int mouseX, final int mouseY, final float partial) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
@@ -74,7 +77,7 @@ public class ToggleButton extends Button implements ITooltip {
}
@Override
public String getMessage() {
public ITextComponent getMessage() {
if (this.displayName != null) {
String name = I18n.format(this.displayName);
String value = I18n.format(this.displayHint);
@@ -97,9 +100,9 @@ public class ToggleButton extends Button implements ITooltip {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
return new StringTextComponent(name + '\n' + sb);
}
return "";
return new StringTextComponent("");
}
@Override