Skip to content

Commit

Permalink
Merge branch '1.20.3' of https://github.com/IrisShaders/Iris into 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Dec 24, 2023
2 parents c730f72 + da9011d commit be36a42
Show file tree
Hide file tree
Showing 45 changed files with 556 additions and 803 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.coderbot.batchedentityrendering.mixin;

import com.mojang.blaze3d.vertex.BufferBuilder;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;

@Mixin(MultiBufferSource.BufferSource.class)
public interface BufferSourceAccessor {
@Accessor
Map<RenderType, BufferBuilder> getFixedBuffers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.coderbot.batchedentityrendering.impl.MemoryTrackingBuffer;
import net.coderbot.batchedentityrendering.impl.MemoryTrackingRenderBuffers;
import net.coderbot.batchedentityrendering.impl.RenderBuffersExt;
import net.minecraft.client.renderer.ChunkBufferBuilderPack;
import net.minecraft.client.renderer.SectionBufferBuilderPack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.OutlineBufferSource;
import net.minecraft.client.renderer.RenderBuffers;
Expand Down Expand Up @@ -45,11 +45,7 @@ public class MixinRenderBuffers implements RenderBuffersExt, MemoryTrackingRende

@Shadow
@Final
private ChunkBufferBuilderPack fixedBufferPack;

@Shadow
@Final
private SortedMap<RenderType, BufferBuilder> fixedBuffers;
private SectionBufferBuilderPack fixedBufferPack;

@Inject(method = "bufferSource", at = @At("HEAD"), cancellable = true)
private void batchedentityrendering$replaceBufferSource(CallbackInfoReturnable<MultiBufferSource.BufferSource> cir) {
Expand Down Expand Up @@ -125,8 +121,9 @@ public int getMaxBegins() {
@Override
public void freeAndDeleteBuffers() {
buffered.freeAndDeleteBuffer();
((ChunkBufferBuilderPackAccessor) this.fixedBufferPack).getBuilders().values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
fixedBuffers.values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
((SectionBufferBuilderPackAccessor) this.fixedBufferPack).getBuilders().values().forEach(bufferBuilder -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
((BufferSourceAccessor) bufferSource).getFixedBuffers().forEach((renderType, bufferBuilder) -> ((MemoryTrackingBuffer) bufferBuilder).freeAndDeleteBuffer());
((BufferSourceAccessor) bufferSource).getFixedBuffers().clear();
((MemoryTrackingBuffer) ((OutlineBufferSourceAccessor) outlineBufferSource).getOutlineBufferSource()).freeAndDeleteBuffer();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package net.coderbot.batchedentityrendering.mixin;

import com.mojang.blaze3d.vertex.BufferBuilder;
import net.minecraft.client.renderer.ChunkBufferBuilderPack;
import net.minecraft.client.renderer.SectionBufferBuilderPack;
import net.minecraft.client.renderer.RenderType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;

@Mixin(ChunkBufferBuilderPack.class)
public interface ChunkBufferBuilderPackAccessor {
@Mixin(SectionBufferBuilderPack.class)
public interface SectionBufferBuilderPackAccessor {
@Accessor
Map<RenderType, BufferBuilder> getBuilders();
}
2 changes: 1 addition & 1 deletion src/main/java/net/coderbot/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class Iris {
private static boolean fallback;

// Change this for snapshots!
private static String backupVersionNumber = "1.19.4";
private static String backupVersionNumber = "1.20.3";

public Iris() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class IrisCommonVertexAttributes {
public static CommonVertexAttribute TANGENT;
public static CommonVertexAttribute MID_TEX_COORD;
public static CommonVertexAttribute BLOCK_ID;
public static CommonVertexAttribute ENTITY_ID;
public static CommonVertexAttribute MID_BLOCK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected void init() {

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
this.renderBackground(guiGraphics);
this.renderBackground(guiGraphics, mouseX, mouseY, delta);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 90, 0xFFFFFF);
message.renderCentered(guiGraphics, this.width / 2, 110, 9, 0xFFFFFF);
super.render(guiGraphics, mouseX, mouseY, delta);
Expand Down
120 changes: 120 additions & 0 deletions src/main/java/net/coderbot/iris/gui/OldImageButton.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package net.coderbot.iris.gui;

import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

@Environment(EnvType.CLIENT)
public class OldImageButton extends Button {
protected final ResourceLocation resourceLocation;
protected final int xTexStart;
protected final int yTexStart;
protected final int yDiffTex;
protected final int textureWidth;
protected final int textureHeight;

public OldImageButton(
int pImageButton0, int pInt1, int pInt2, int pInt3, int pInt4, int pInt5, ResourceLocation pResourceLocation6, Button.OnPress pButton$OnPress7
) {
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt3, pResourceLocation6, 256, 256, pButton$OnPress7);
}

public OldImageButton(
int pImageButton0,
int pInt1,
int pInt2,
int pInt3,
int pInt4,
int pInt5,
int pInt6,
ResourceLocation pResourceLocation7,
Button.OnPress pButton$OnPress8
) {
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt6, pResourceLocation7, 256, 256, pButton$OnPress8);
}

public OldImageButton(
int pImageButton0,
int pInt1,
int pInt2,
int pInt3,
int pInt4,
int pInt5,
int pInt6,
ResourceLocation pResourceLocation7,
int pInt8,
int pInt9,
Button.OnPress pButton$OnPress10
) {
this(pImageButton0, pInt1, pInt2, pInt3, pInt4, pInt5, pInt6, pResourceLocation7, pInt8, pInt9, pButton$OnPress10, CommonComponents.EMPTY);
}

public OldImageButton(
int pImageButton0,
int pInt1,
int pInt2,
int pInt3,
int pInt4,
int pInt5,
int pInt6,
ResourceLocation pResourceLocation7,
int pInt8,
int pInt9,
Button.OnPress pButton$OnPress10,
Component pComponent11
) {
super(pImageButton0, pInt1, pInt2, pInt3, pComponent11, pButton$OnPress10, DEFAULT_NARRATION);
this.textureWidth = pInt8;
this.textureHeight = pInt9;
this.xTexStart = pInt4;
this.yTexStart = pInt5;
this.yDiffTex = pInt6;
this.resourceLocation = pResourceLocation7;
}

@Override
public void renderWidget(GuiGraphics pImageButton0, int pInt1, int pInt2, float pFloat3) {
this.renderTexture(
pImageButton0,
this.resourceLocation,
this.getX(),
this.getY(),
this.xTexStart,
this.yTexStart,
this.yDiffTex,
this.width,
this.height,
this.textureWidth,
this.textureHeight
);
}

public void renderTexture(
GuiGraphics pAbstractWidget0,
ResourceLocation pResourceLocation1,
int pInt2,
int pInt3,
int pInt4,
int pInt5,
int pInt6,
int pInt7,
int pInt8,
int pInt9,
int pInt10
) {
int lvInt12 = pInt5;
if (!this.isActive()) {
lvInt12 = pInt5 + pInt6 * 2;
} else if (this.isHoveredOrFocused()) {
lvInt12 = pInt5 + pInt6;
}

RenderSystem.enableDepthTest();
pAbstractWidget0.blit(pResourceLocation1, pInt2, pInt3, (float)pInt4, (float)lvInt12, pInt7, pInt8, pInt9, pInt10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,4 @@ protected void init() {

widget.visitWidgets(this::addRenderableWidget);
}

@Override
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
if (this.minecraft.level == null) {
this.renderBackground(guiGraphics);
} else {
guiGraphics.fillGradient(0, 0, width, height, 0x4F232323, 0x4F232323);
}
super.render(guiGraphics, i, j, f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

public class IrisContainerObjectSelectionList<E extends ContainerObjectSelectionList.Entry<E>> extends ContainerObjectSelectionList<E> {
public IrisContainerObjectSelectionList(Minecraft client, int width, int height, int top, int bottom, int left, int right, int itemHeight) {
super(client, width, height, top, bottom, itemHeight);

this.x0 = left;
this.x1 = right;
super(client, width, height, top, itemHeight);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

public class IrisObjectSelectionList<E extends AbstractSelectionList.Entry<E>> extends AbstractSelectionList<E> {
public IrisObjectSelectionList(Minecraft client, int width, int height, int top, int bottom, int left, int right, int itemHeight) {
super(client, width, height, top, bottom, itemHeight);

this.x0 = left;
this.x1 = right;
super(client, width, height, top, itemHeight);
}

@Override
Expand All @@ -26,7 +23,7 @@ public void select(int entry) {
}

@Override
public void updateNarration(NarrationElementOutput p0) {
public void updateWidgetNarration(NarrationElementOutput p0) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.client.gui.navigation.ScreenDirection;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextColor;
Expand All @@ -46,13 +47,28 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
private OptionMenuContainer container;

public ShaderPackOptionList(ShaderPackScreen screen, NavigationController navigation, ShaderPack pack, Minecraft client, int width, int height, int top, int bottom, int left, int right) {
super(client, width, height, top, bottom, left, right, 24);
super(client, width, bottom, top, bottom, left, right, 24);
this.navigation = navigation;
this.screen = screen;
this.setRenderBackground(false);

applyShaderPack(pack);
}

@Override
protected void renderDecorations(GuiGraphics pAbstractSelectionList0, int pInt1, int pInt2) {
// Renders top/bottom dirt
int lvInt9 = 32;
pAbstractSelectionList0.setColor(0.25F, 0.25F, 0.25F, 1.0F);
pAbstractSelectionList0.blit(Screen.BACKGROUND_LOCATION, this.getX(), 0, 0.0F, 0.0F, this.width, this.getY(), 32, 32);
pAbstractSelectionList0.blit(Screen.BACKGROUND_LOCATION, this.getX(), this.getBottom(), 0.0F, 0.0F, this.width, this.height, 32, 32);
pAbstractSelectionList0.setColor(1.0F, 1.0F, 1.0F, 1.0F);
int lvInt10 = 4;
pAbstractSelectionList0.fillGradient(RenderType.guiOverlay(), this.getX(), this.getY(), this.getRight(), this.getY() + 4, -16777216, 0, 0);
pAbstractSelectionList0.fillGradient(RenderType.guiOverlay(), this.getX(), this.getBottom() - 4, this.getRight(), this.getBottom(), 0, -16777216, 0);
super.renderDecorations(pAbstractSelectionList0, pInt1, pInt2);
}

public void applyShaderPack(ShaderPack pack) {
this.container = pack.getMenuContainer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextColor;
Expand Down Expand Up @@ -47,9 +49,10 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
private ShaderPackEntry applied = null;

public ShaderPackSelectionList(ShaderPackScreen screen, Minecraft client, int width, int height, int top, int bottom, int left, int right) {
super(client, width, height, top, bottom, left, right, 20);
super(client, width, bottom, top, bottom, left, right, 20);
WatchKey key1;
WatchService watcher1;
this.setRenderBackground(false);

this.screen = screen;
this.topButtonRow = new TopButtonRowEntry(this, Iris.getIrisConfig().areShadersEnabled());
Expand Down Expand Up @@ -82,7 +85,7 @@ public boolean keyPressed(int pContainerEventHandler0, int pInt1, int pInt2) {
}

@Override
public void render(GuiGraphics pAbstractSelectionList0, int pInt1, int pInt2, float pFloat3) {
public void renderWidget(GuiGraphics pAbstractSelectionList0, int pInt1, int pInt2, float pFloat3) {
if (keyValid) {
for (WatchEvent<?> event : key.pollEvents()) {
if (event.kind() == StandardWatchEventKinds.OVERFLOW) continue;
Expand All @@ -94,7 +97,7 @@ public void render(GuiGraphics pAbstractSelectionList0, int pInt1, int pInt2, fl
keyValid = key.reset();
}

super.render(pAbstractSelectionList0, pInt1, pInt2, pFloat3);
super.renderWidget(pAbstractSelectionList0, pInt1, pInt2, pFloat3);
}

public void close() throws IOException {
Expand Down Expand Up @@ -176,6 +179,20 @@ public void addPackEntry(int index, String name) {
this.addEntry(entry);
}

@Override
protected void renderDecorations(GuiGraphics pAbstractSelectionList0, int pInt1, int pInt2) {
// Renders top/bottom dirt
int lvInt9 = 32;
pAbstractSelectionList0.setColor(0.25F, 0.25F, 0.25F, 1.0F);
pAbstractSelectionList0.blit(Screen.BACKGROUND_LOCATION, this.getX(), 0, 0.0F, 0.0F, this.width, this.getY(), 32, 32);
pAbstractSelectionList0.blit(Screen.BACKGROUND_LOCATION, this.getX(), this.getBottom(), 0.0F, 0.0F, this.width, this.height, 32, 32);
pAbstractSelectionList0.setColor(1.0F, 1.0F, 1.0F, 1.0F);
int lvInt10 = 4;
pAbstractSelectionList0.fillGradient(RenderType.guiOverlay(), this.getX(), this.getY(), this.getRight(), this.getY() + 4, -16777216, 0, 0);
pAbstractSelectionList0.fillGradient(RenderType.guiOverlay(), this.getX(), this.getBottom() - 4, this.getRight(), this.getBottom(), 0, -16777216, 0);

}

public void addLabelEntries(Component ... lines) {
for (Component text : lines) {
this.addEntry(new LabelEntry(text));
Expand Down
Loading

0 comments on commit be36a42

Please sign in to comment.