Skip to content

Commit

Permalink
just work
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jun 27, 2024
1 parent 75ca581 commit 6c99ff2
Show file tree
Hide file tree
Showing 24 changed files with 180 additions and 227 deletions.
19 changes: 5 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,20 @@ buildscript {
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:1.1-SNAPSHOT"
classpath "net.fabricmc:fabric-loom:1.7-SNAPSHOT"
}
}

plugins {
id 'io.github.juuxel.loom-vineflower' version '1.+' apply false
}

apply plugin: 'fabric-loom'
apply plugin: 'io.github.juuxel.loom-vineflower'
apply plugin: 'java'
apply plugin: 'idea'

group 'com.irtimaled'
version project.buildVersion + '-' + project.minecraft_version
archivesBaseName = 'BBOutlineReloaded'

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
Expand All @@ -35,7 +30,7 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

it.options.release = 17
it.options.release = 21
}

repositories {
Expand Down Expand Up @@ -71,7 +66,7 @@ processResources {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()
}
Expand All @@ -91,10 +86,6 @@ jar {
}
}

afterEvaluate {
remapJar.classifier = 'fabric'
}

afterEvaluate {
migrateMappings.configure {
outputDir = project.file("src/main/java")
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx4G
name=bbor
buildVersion=2.6
# leave a space to reduce merge conflicts on version change
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.2
minecraft_version=1.21
yarn_mappings=1.21+build.4
loader_version=0.15.11

#Fabric api
fabric_version=0.91.3+1.20.4
fabric_version=0.100.4+1.21

modmenu_version=4.1.1
modmenu_version=11.0.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Tue May 26 09:16:06 PDT 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
112 changes: 35 additions & 77 deletions src/main/java/com/irtimaled/bbor/client/gui/ControlList.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TabButtonWidget;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -34,7 +37,6 @@ public class ControlList implements IControlSet {
protected int contentHeight = PADDING;
private double amountScrolled;
private boolean clickedScrollbar;
private boolean transparentBackground;
private IControl focused;
private boolean isDragging;

Expand Down Expand Up @@ -177,13 +179,14 @@ public void render(DrawContext ctx, int mouseX, int mouseY) {

int listTop = this.top + PADDING - (int) this.amountScrolled;

Screen.renderBackgroundTexture(ctx, Screen.MENU_BACKGROUND_TEXTURE, 0, top, 0.0F, 0.0F, width, height);
drawEntries(ctx, mouseX, mouseY, listTop);

RenderHelper.enableDepthTest();
RenderHelper.depthFuncAlways();

this.overlayBackground(0, this.top);
this.overlayBackground(this.bottom, this.height);
this.overlayBackground(ctx, 0, this.top, Screen.HEADER_SEPARATOR_TEXTURE);
this.overlayBackground(ctx, this.bottom, this.height, Screen.FOOTER_SEPARATOR_TEXTURE);
RenderHelper.depthFuncLessEqual();
RenderHelper.disableDepthTest();
RenderHelper.enableBlend();
Expand All @@ -202,19 +205,6 @@ public void render(DrawContext ctx, int mouseX, int mouseY) {
RenderHelper.disableBlend();
}

private void drawListBackground(MatrixStack matrixStack) {
MinecraftClient.getInstance().getTextureManager().bindTexture(Screen.OPTIONS_BACKGROUND_TEXTURE);
Renderer.startTextured()
.setMatrixStack(matrixStack)
.setColor(32, 32, 32)
.setAlpha(255)
.addPoint(0, this.bottom, 0.0D, (float) 0 / 32.0F, (float) (this.bottom + (int) this.amountScrolled) / 32.0F)
.addPoint(this.width, this.bottom, 0.0D, (float) this.width / 32.0F, (float) (this.bottom + (int) this.amountScrolled) / 32.0F)
.addPoint(this.width, this.top, 0.0D, (float) this.width / 32.0F, (float) (this.top + (int) this.amountScrolled) / 32.0F)
.addPoint(0, this.top, 0.0D, (float) 0 / 32.0F, (float) (this.top + (int) this.amountScrolled) / 32.0F)
.render();
}

private void drawEntries(DrawContext ctx, int mouseX, int mouseY, int top) {
for (ControlListEntry entry : this.entries) {
if (!entry.isVisible()) continue;
Expand All @@ -224,7 +214,7 @@ private void drawEntries(DrawContext ctx, int mouseX, int mouseY, int top) {

int height = entry.getControlHeight();
int bottom = top + height;
if(top <= this.bottom && bottom >= this.top) {
if (bottom >= this.top && top <= this.bottom) {
drawEntry(ctx, mouseX, mouseY, top, entry, height);
} else {
entry.update();
Expand All @@ -237,34 +227,10 @@ protected void drawEntry(DrawContext ctx, int mouseX, int mouseY, int top, Contr
entry.render(ctx, mouseX, mouseY);
}

private void overlayBackground(int top, int bottom) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
RenderSystem.setShaderTexture(0, Screen.OPTIONS_BACKGROUND_TEXTURE);

bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
bufferBuilder
.vertex(0, bottom, -100.0D)
.texture(0.0F, (float) bottom / 32.0F)
.color(64, 64, 64, 255)
.next();
bufferBuilder
.vertex(this.width, bottom, -100.0D)
.texture((float) this.width / 32.0F, (float) bottom / 32.0F)
.color(64, 64, 64, 255)
.next();
bufferBuilder
.vertex(this.width, top, -100.0D)
.texture((float) this.width / 32.0F, (float) top / 32.0F)
.color(64, 64, 64, 255)
.next();
bufferBuilder
.vertex(0, top, -100.0D)
.texture(0.0f, (float) top / 32.0F)
.color(64, 64, 64, 255)
.next();
tessellator.draw();
private void overlayBackground(DrawContext context, int top, int bottom, Identifier texture) {
RenderSystem.enableBlend();
context.drawTexture(texture, 0, top, 0.0F, 0.0F, 0, bottom, 32, 2);
RenderSystem.disableBlend();
}

private void drawScrollBar(int maxScroll) {
Expand All @@ -275,28 +241,26 @@ private void drawScrollBar(int maxScroll) {
}

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
RenderHelper.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorProgram);

bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);

bufferBuilder.vertex(this.scrollBarLeft, this.bottom, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.bottom, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.top, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, this.top, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, this.bottom, 0.0F).color(0, 0, 0, 255);
bufferBuilder.vertex(this.width, this.bottom, 0.0F).color(0, 0, 0, 255);
bufferBuilder.vertex(this.width, this.top, 0.0F).color(0, 0, 0, 255);
bufferBuilder.vertex(this.scrollBarLeft, this.top, 0.0F).color(0, 0, 0, 255);

bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight, 0.0D).color(128, 128, 128, 255).next();
bufferBuilder.vertex(this.width, scrollBarTop + scrollBarHeight, 0.0D).color(128, 128, 128, 255).next();
bufferBuilder.vertex(this.width, scrollBarTop, 0.0D).color(128, 128, 128, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0D).color(128, 128, 128, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight, 0.0F).color(128, 128, 128, 255);
bufferBuilder.vertex(this.width, scrollBarTop + scrollBarHeight, 0.0F).color(128, 128, 128, 255);
bufferBuilder.vertex(this.width, scrollBarTop, 0.0F).color(128, 128, 128, 255);
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0F).color(128, 128, 128, 255);

bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight - 1, 0.0D).color(192, 192, 192, 255).next();
bufferBuilder.vertex(this.width - 1, scrollBarTop + scrollBarHeight - 1, 0.0D).color(192, 192, 192, 255).next();
bufferBuilder.vertex(this.width - 1, scrollBarTop, 0.0D).color(192, 192, 192, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0D).color(192, 192, 192, 255).next();
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight - 1, 0.0F).color(192, 192, 192, 255);
bufferBuilder.vertex(this.width - 1, scrollBarTop + scrollBarHeight - 1, 0.0F).color(192, 192, 192, 255);
bufferBuilder.vertex(this.width - 1, scrollBarTop, 0.0F).color(192, 192, 192, 255);
bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0F).color(192, 192, 192, 255);

tessellator.draw();
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderHelper.enableTexture();
}

Expand All @@ -307,21 +271,19 @@ private void drawOverlayShadows() {
RenderHelper.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();

bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);

bufferBuilder.vertex(0, this.top + 4, 0.0D).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.width, this.top + 4, 0.0D).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.width, this.top, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(0, this.top, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(0, this.top + 4, 0.0F).color(0, 0, 0, 0);
bufferBuilder.vertex(this.width, this.top + 4, 0.0F).color(0, 0, 0, 0);
bufferBuilder.vertex(this.width, this.top, 0.0F).color(0, 0, 0, 255);
bufferBuilder.vertex(0, this.top, 0.0F).color(0, 0, 0, 255);

bufferBuilder.vertex(this.width, this.bottom - 4, 0.0D).color(0, 0, 0, 0).next();
bufferBuilder.vertex(0, this.bottom - 4, 0.0D).color(0, 0, 0, 0).next();
bufferBuilder.vertex(0, this.bottom, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.bottom, 0.0D).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.bottom - 4, 0.0F).color(0, 0, 0, 0);
bufferBuilder.vertex(0, this.bottom - 4, 0.0F).color(0, 0, 0, 0);
bufferBuilder.vertex(0, this.bottom, 0.0F).color(0, 0, 0, 255);
bufferBuilder.vertex(this.width, this.bottom, 0.0F).color(0, 0, 0, 255);

tessellator.draw();
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderHelper.enableTexture();
RenderSystem.disableBlend();
}
Expand All @@ -336,10 +298,6 @@ ControlList section(String title, int columnCount, CreateControl... createContro
return this;
}

void setTransparentBackground() {
this.transparentBackground = true;
}

@Override
public List<? extends IControl> controls() {
return entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ protected void onDoneClicked() {
protected ControlList buildList(int top, int bottom) {
String version = SharedConstants.getGameVersion().getName();
ControlList controlList = new ControlList(this.width, this.height, top, bottom);
if (this.client.world != null) controlList.setTransparentBackground();

controlList
.section(null,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/irtimaled/bbor/client/gui/WorldSaveRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class WorldSaveRow extends ControlListEntry implements Comparable<WorldSaveRow> {
private static final Logger LOGGER = LogManager.getLogger();
private static final DateFormat DATE_FORMAT = new SimpleDateFormat();
private static final Identifier ICON_MISSING = new Identifier("textures/misc/unknown_server.png");
private static final Identifier ICON_MISSING = Identifier.ofVanilla("textures/misc/unknown_server.png");
private static final int ICON_SIZE = 20;
private final MinecraftClient client;
private final LevelSummary worldSummary;
Expand All @@ -48,7 +48,7 @@ public class WorldSaveRow extends ControlListEntry implements Comparable<WorldSa
this.saveLoader = saveLoader;
this.setSelectedEntry = setSelectedEntry;
this.client = MinecraftClient.getInstance();
this.iconLocation = new Identifier("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getName()) + "/icon");
this.iconLocation = Identifier.ofVanilla("worlds/" + Hashing.sha1().hashUnencodedChars(worldSummary.getName()) + "/icon");
this.iconFile = worldSummary.getIconPath().toFile();
if (!this.iconFile.isFile()) {
this.iconFile = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private FeatureUpdater getLegacyStructureDataUtil() {
if (this.legacyStructureDataUtil == null) {
Path dataFolder = this.saveHandler.getWorldDirectory(World.OVERWORLD).resolve("data");
this.legacyStructureDataUtil = FeatureUpdater.create(dimensionId.getDimensionType(),
new PersistentStateManager(dataFolder.toFile(), MinecraftClient.getInstance().getDataFixer()));
new PersistentStateManager(dataFolder.toFile(), MinecraftClient.getInstance().getDataFixer(), MinecraftClient.getInstance().world.getRegistryManager()));
}
return this.legacyStructureDataUtil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public static boolean isSpawnable(World world, BlockPos pos, BlockState spawnBlo
});
final Identifier id = biomeRegistryEntry.getKey().get().getValue();
return spawnBlockState.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIFIED_PIGLIN : EntityType.ZOMBIE) &&
(id == null || !id.equals(new Identifier("minecraft", "mushroom_fields")) &&
!id.equals(new Identifier("minecraft", "deep_dark")));
(id == null || !id.equals(Identifier.ofVanilla("mushroom_fields")) &&
!id.equals(Identifier.ofVanilla("deep_dark")));
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.irtimaled.bbor.client.renderers;

import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
Expand Down Expand Up @@ -29,7 +30,7 @@ public static Renderer startTextured() {
}

private static final Tessellator tessellator = Tessellator.getInstance();
private static final BufferBuilder bufferBuilder = tessellator.getBuffer();
private static BufferBuilder bufferBuilder = null;

private int red;
private int green;
Expand All @@ -38,7 +39,7 @@ public static Renderer startTextured() {
private MatrixStack matrixStack;

private Renderer(VertexFormat.DrawMode glMode, VertexFormat vertexFormat) {
bufferBuilder.begin(glMode, vertexFormat);
bufferBuilder = tessellator.begin(glMode, vertexFormat);
this.glMode = glMode;
}

Expand Down Expand Up @@ -98,7 +99,7 @@ public void render() {
if (glMode == VertexFormat.DrawMode.QUADS) {
// bufferBuilder.sortFrom((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ()); // TODO
}
tessellator.draw();
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
matrixStack.pop();
}

Expand All @@ -115,6 +116,6 @@ private void color() {
}

private void end() {
bufferBuilder.next();
// bufferBuilder.next();
}
}
Loading

0 comments on commit 6c99ff2

Please sign in to comment.