Skip to content

Commit

Permalink
Backport for Minecraft 1.16.1
Browse files Browse the repository at this point in the history
---

Signed-off-by: AterAnimAvis <AterAnimAvis@gmail.com>
  • Loading branch information
AterAnimAvis committed Sep 20, 2020
1 parent 3309f35 commit d9e4cb8
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 105 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ apply plugin: 'net.minecraftforge.gradle'

group = "com.unascribed"
archivesBaseName = "BlockRenderer"
version = "1.16.3-1.3.0"
version = "1.16.1-1.3.0"

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.VERSION_1_8

minecraft {
mappings channel: 'snapshot', version: '20200723-1.16.1'
mappings channel: 'snapshot', version: '20200820-1.16.1'

// accessTransformer = file('src/main/resources/META-INF/block_renderer_at.cfg')

Expand Down Expand Up @@ -54,7 +54,7 @@ minecraft {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.16.2-33.0.19'
minecraft 'net.minecraftforge:forge:1.16.1-32.0.108'

// Javax Annotations (N.B. ForgeGradle currently provides this)
implementation 'com.google.code.findbugs:jsr305:3+'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.unascribed.blockrenderer.render.impl;

import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.unascribed.blockrenderer.lib.TileRenderer;
Expand All @@ -12,10 +11,10 @@
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.ITextProperties;
import net.minecraftforge.registries.ForgeRegistries;
import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -79,12 +78,12 @@ public void render(ItemStack value) {
renderer.beginTile();
RenderSystem.pushMatrix();

/* Clear Framebuffer */
RenderSystem.clearColor(0, 0, 0, 0);
RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
/* Clear Framebuffer */
RenderSystem.clearColor(0, 0, 0, 0);
RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);

/* Render */
itemRenderer.renderItemAndEffectIntoGUI(value, 0, 0);
/* Render */
itemRenderer.renderItemAndEffectIntoGUI(value, 0, 0);

RenderSystem.popMatrix();
} while (renderer.endTile());
Expand Down Expand Up @@ -133,8 +132,8 @@ public void renderTooltip(MatrixStack stack, ItemStack value, int displayWidth,
if (font == null) font = client.fontRenderer;

int width = 0;
for (IReorderingProcessor s : Lists.transform(list, ITextComponent::func_241878_f)) {
int j = font.func_243245_a(s);
for (ITextProperties s : list) {
int j = font.func_238414_a_(s);
if (j > width) width = j;
}
// End copied code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public UpdateableSliderWidget(GameSettings settings, int x, int y, int width, in
}

public void update(double desired) {
/* mcp: value */ field_230683_b_ = option.normalizeValue(desired);
sliderValue = option.normalizeValue(desired);

/* mcp: applyValue */ func_230972_a_();
/* mcp: applyValue */
func_230972_a_();

/* mcp: updateMessage */ func_230979_b_();
/* mcp: updateMessage */
func_230979_b_();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public ExtendedSliderPercentageOption(String translationKey, double minValueIn,
}

public ITextComponent getDisplayPrefix() {
return super.func_243220_a();
return super.func_238238_a_();
}
}
134 changes: 67 additions & 67 deletions src/main/java/com/unascribed/blockrenderer/utils/Rendering.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,73 @@
* Static versions of AbstractGui and Screen utility methods.
*/
public interface Rendering {
class DummyScreen extends Screen {

protected DummyScreen() {
super(new StringTextComponent(NAME + " Dummy Screen"));
}

@Override
public List<ITextComponent> getTooltipFromItem(ItemStack p_231151_1_) {
return super.getTooltipFromItem(p_231151_1_);
}
}

DummyScreen GUI = new DummyScreen();

static void drawCenteredString(MatrixStack stack, FontRenderer fontRendererIn, String text, int x, int y, int color) {
AbstractGui.drawCenteredString(stack, fontRendererIn, text, x, y, color);
}
static void drawRect(MatrixStack stack, int left, int top, int right, int bottom, int color) {
AbstractGui.fill(stack, left, top, right, bottom, color);
}
static void drawHoveringText(MatrixStack stack, List<ITextComponent> textLines, int x, int y) {
GUI./* mcp: renderTooltip */func_243308_b(stack, textLines, x, y);
}

static void drawHoveringText(Screen owner, MatrixStack stack, List<ITextComponent> textLines, int x, int y) {
GUI.init(Minecraft.getInstance(), owner.width, owner.height);
GUI./* mcp: renderTooltip */func_243308_b(stack, textLines, x, y);
}
static void drawBackground(int width, int height) {
GUI.init(Minecraft.getInstance(), width, height);
GUI.renderDirtBackground(0);
}

static void setupOverlayRendering() {
Minecraft client = Minecraft.getInstance();
MainWindow window = client.getMainWindow();
double scaleFactor = window.getGuiScaleFactor();

RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity();
RenderSystem.ortho(0.0D, window.getFramebufferWidth() / scaleFactor, window.getFramebufferHeight() / scaleFactor, 0.0D, 1000.0D, 3000.0D);
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
}

static void setupOverlayRendering(TileRenderer renderer) {
RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);

/* Projection */
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity();

/* We flip the bottom and top parameters here so we don't need to process the image just fix a culling issue */
/* This results in a minor speed up / lower memory usage */
renderer.ortho(0.0D, renderer.imageWidth, 0.0D, renderer.imageHeight, 1000.0D, 3000.0D);

/* Model View */
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
}
class DummyScreen extends Screen {

protected DummyScreen() {
super(new StringTextComponent(NAME + " Dummy Screen"));
}

@Override
public List<ITextComponent> getTooltipFromItem(ItemStack p_231151_1_) {
return super.getTooltipFromItem(p_231151_1_);
}
}

DummyScreen GUI = new DummyScreen();


static void drawCenteredString(MatrixStack stack, FontRenderer fontRendererIn, String text, int x, int y, int color) {
GUI.drawCenteredString(stack, fontRendererIn, text, x, y, color);
}

static void drawRect(MatrixStack stack, int left, int top, int right, int bottom, int color) {
AbstractGui.fill(stack, left, top, right, bottom, color);
}

static void drawHoveringText(MatrixStack stack, List<ITextComponent> textLines, int x, int y) {
GUI.renderTooltip(stack, textLines, x, y);
}

static void drawHoveringText(Screen owner, MatrixStack stack, List<ITextComponent> textLines, int x, int y) {
GUI.init(Minecraft.getInstance(), owner.width, owner.height);
GUI.renderTooltip(stack, textLines, x, y);
}

static void drawBackground(int width, int height) {
GUI.init(Minecraft.getInstance(), width, height);
GUI.renderDirtBackground(0);
}

static void setupOverlayRendering() {
Minecraft client = Minecraft.getInstance();
MainWindow window = client.getMainWindow();
double scaleFactor = window.getGuiScaleFactor();

RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity();
RenderSystem.ortho(0.0D, window.getFramebufferWidth() / scaleFactor, window.getFramebufferHeight() / scaleFactor, 0.0D, 1000.0D, 3000.0D);
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
}

static void setupOverlayRendering(TileRenderer renderer) {
RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);

/* Projection */
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity();

/* We flip the bottom and top parameters here so we don't need to process the image just fix a culling issue */
/* This results in a minor speed up / lower memory usage */
renderer.ortho(0.0D, renderer.imageWidth, 0.0D, renderer.imageHeight, 1000.0D, 3000.0D);

/* Model View */
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
}


}
44 changes: 22 additions & 22 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
modLoader="javafml"
license="MIT License"
loaderVersion="[32,35)"
issueTrackerURL="https://github.com/AterAnimAvis/BlockRenderer/issues"
modLoader = "javafml"
license = "MIT License"
loaderVersion = "[32,33)"
issueTrackerURL = "https://github.com/AterAnimAvis/BlockRenderer/issues"
[[mods]]
modId="block_renderer"
version="${file.jarVersion}"
displayName="BlockRenderer"
displayURL="https://unascribed.com"
logoFile="logo-blockrenderer.png"
credits="Una, xbony2, modmuss50, AterAnimAvis, Brian Paul (TR Library)"
authors="Una"
description="It renders blocks and items."
modId = "block_renderer"
version = "${file.jarVersion}"
displayName = "BlockRenderer"
displayURL = "https://unascribed.com"
logoFile = "logo-blockrenderer.png"
credits = "Una, xbony2, modmuss50, AterAnimAvis, Brian Paul (TR Library)"
authors = "Una"
description = "It renders blocks and items."

[[dependencies.block_renderer]]
modId="forge"
mandatory=true
versionRange="[32,35)"
ordering="NONE"
side="BOTH"
modId = "forge"
mandatory = true
versionRange = "[32,33)"
ordering = "NONE"
side = "BOTH"
[[dependencies.block_renderer]]
modId="minecraft"
mandatory=true
versionRange="[1.16,1.17)"
ordering="NONE"
side="BOTH"
modId = "minecraft"
mandatory = true
versionRange = "[1.16.1]"
ordering = "NONE"
side = "BOTH"

0 comments on commit d9e4cb8

Please sign in to comment.