Skip to content

Commit

Permalink
Update to 20w20b
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed May 15, 2020
1 parent 9743d57 commit 16eb604
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=20w17a
yarn_mappings=20w17a+build.4
loader_version=0.8.2+build.194
minecraft_version=20w20b
yarn_mappings=20w20b+build.7
loader_version=0.8.3+build.196

# Mod Properties
mod_version = 1.9.0
mod_version = 1.9.1
maven_group = io.github.cottonmc
archives_base_name = LibGui

# Dependencies
fabric_version=0.6.2+build.327-1.16
jankson_version=2.0.1+j1.2.0
fabric_version=0.10.9+build.346-1.16
jankson_version=2.1.0+j1.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void paint(int mouseX, int mouseY) {
}

if (getTitle() != null) {
textRenderer.method_27528(ScreenDrawing.matrices, getTitle(), left, top, description.getTitleColor());
textRenderer.draw(ScreenDrawing.matrices, getTitle(), left, top, description.getTitleColor());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void paint(int mouseX, int mouseY) {
}

if (getTitle() != null) {
textRenderer.method_27528(ScreenDrawing.matrices, getTitle(), x, y, description.getTitleColor());
textRenderer.draw(ScreenDrawing.matrices, getTitle(), x, y, description.getTitleColor());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ public static void drawString(String s, Alignment align, int x, int y, int width
}
break;
case CENTER: {
int wid = MinecraftClient.getInstance().textRenderer.getStringWidth(s);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
int l = (width/2) - (wid/2);
MinecraftClient.getInstance().textRenderer.draw(matrices, s, x+l, y, color);
}
break;
case RIGHT: {
int wid = MinecraftClient.getInstance().textRenderer.getStringWidth(s);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
int l = width - wid;
MinecraftClient.getInstance().textRenderer.draw(matrices, s, x+l, y, color);
}
Expand All @@ -343,19 +343,19 @@ public static void drawString(String s, Alignment align, int x, int y, int width
public static void drawString(Text text, Alignment align, int x, int y, int width, int color) {
switch(align) {
case LEFT: {
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
}
break;
case CENTER: {
int wid = MinecraftClient.getInstance().textRenderer.method_27525(text);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
int l = (width/2) - (wid/2);
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x+l, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x+l, y, color);
}
break;
case RIGHT: {
int wid = MinecraftClient.getInstance().textRenderer.method_27525(text);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
int l = width - wid;
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x+l, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x+l, y, color);
}
break;
}
Expand All @@ -378,13 +378,13 @@ public static void drawStringWithShadow(String s, Alignment align, int x, int y,
}
break;
case CENTER: {
int wid = MinecraftClient.getInstance().textRenderer.getStringWidth(s);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
int l = (width/2) - (wid/2);
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, s, x+l, y, color);
}
break;
case RIGHT: {
int wid = MinecraftClient.getInstance().textRenderer.getStringWidth(s);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(s);
int l = width - wid;
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, s, x+l, y, color);
}
Expand All @@ -405,19 +405,19 @@ public static void drawStringWithShadow(String s, Alignment align, int x, int y,
public static void drawStringWithShadow(Text text, Alignment align, int x, int y, int width, int color) {
switch(align) {
case LEFT: {
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
}
break;
case CENTER: {
int wid = MinecraftClient.getInstance().textRenderer.method_27525(text);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
int l = (width/2) - (wid/2);
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x+l, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x+l, y, color);
}
break;
case RIGHT: {
int wid = MinecraftClient.getInstance().textRenderer.method_27525(text);
int wid = MinecraftClient.getInstance().textRenderer.getWidth(text);
int l = width - wid;
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x+l, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x+l, y, color);
}
break;
}
Expand All @@ -444,7 +444,7 @@ public static void drawString(String s, int x, int y, int color) {
* @param color the text color
*/
public static void drawString(Text text, int x, int y, int color) {
MinecraftClient.getInstance().textRenderer.method_27528(matrices, text, x, y, color);
MinecraftClient.getInstance().textRenderer.draw(matrices, text, x, y, color);
}

/**
Expand All @@ -453,7 +453,7 @@ public static void drawString(Text text, int x, int y, int color) {
@Deprecated
public static void drawCenteredWithShadow(String s, int x, int y, int color) {
TextRenderer render = MinecraftClient.getInstance().textRenderer;
render.drawWithShadow(matrices, s, (float)(x - render.getStringWidth(s) / 2), (float)y, color);
render.drawWithShadow(matrices, s, (float)(x - render.getWidth(s) / 2), (float)y, color);
}

public static int colorAtOpacity(int opaque, float opacity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void paintBackground(int x, int y, int mouseX, int mouseY) {
MinecraftClient mc = MinecraftClient.getInstance();
ItemRenderer renderer = mc.getItemRenderer();
renderer.zOffset = 100f;
renderer.renderGuiItem(mc.player, items.get(current), getWidth() / 2 - 9, getHeight() / 2 - 9);
renderer.method_27951(mc.player, items.get(current), getWidth() / 2 - 9, getHeight() / 2 - 9);
renderer.zOffset = 0f;

RenderSystem.popMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onClick(int x, int y, int button) {
@Nullable
private Text getTextAt(int x, int y) {
if (isWithinBounds(x, y)) {
return MinecraftClient.getInstance().textRenderer.method_27527().method_27489(text, x);
return MinecraftClient.getInstance().textRenderer.trimToWidth(text, x);
}
return null;
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.Texts;
import net.minecraft.text.Style;
import net.minecraft.text.Text;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -54,7 +52,7 @@ public boolean canResize() {
@Environment(EnvType.CLIENT)
private void wrapLines() {
TextRenderer font = MinecraftClient.getInstance().textRenderer;
wrappedLines = font.method_27527().method_27491(text, width, Style.field_24360, false);
wrappedLines = font.wrapLines(text, width);
}

@Environment(EnvType.CLIENT)
Expand All @@ -65,7 +63,7 @@ protected Text getTextAt(int x, int y) {

if (lineIndex >= 0 && lineIndex < wrappedLines.size()) {
Text line = wrappedLines.get(lineIndex);
return font.method_27527().method_27489(line, x);
return font.getTextHandler().trimToWidth(line, x);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void renderButton(int x, int y) {
int textColor = this.editable ? this.enabledColor : this.uneditableColor;

//TODO: Scroll offset
String trimText = font.method_27523(this.text, this.width-OFFSET_X_TEXT);
String trimText = font.trimToWidth(this.text, this.width-OFFSET_X_TEXT);

boolean selection = (select!=-1);
boolean focused = this.isFocused(); //this.isFocused() && this.focusedTicks / 6 % 2 == 0 && boolean_1; //Blinks the cursor
Expand Down Expand Up @@ -676,7 +676,7 @@ public static int getCaretPos(String s, int x) {
TextRenderer font = MinecraftClient.getInstance().textRenderer;
int lastAdvance = 0;
for(int i=0; i<s.length()-1; i++) {
int advance = font.getStringWidth(s.substring(0,i+1));
int advance = font.getWidth(s.substring(0,i+1));
int charAdvance = advance-lastAdvance;
if (x<advance + (charAdvance/2)) return i+1;

Expand All @@ -697,7 +697,7 @@ public static int getCaretOffset(String s, int pos) {
if (pos==0) return 0;//-1;

TextRenderer font = MinecraftClient.getInstance().textRenderer;
int ofs = font.getStringWidth(s.substring(0, pos))+1;
int ofs = font.getWidth(s.substring(0, pos))+1;
return ofs; //(font.isRightToLeft()) ? -ofs : ofs;
}
}

0 comments on commit 16eb604

Please sign in to comment.