Skip to content

Commit

Permalink
Backport to Minecraft 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantonik committed Feb 15, 2024
1 parent 2f3f7b5 commit f588f1e
Show file tree
Hide file tree
Showing 84 changed files with 179 additions and 4,809 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
mkdir artifacts
cp Fabric/build/libs/*.jar artifacts
cp Forge/build/libs/*.jar artifacts
cp NeoForge/build/libs/*.jar artifacts
- name: 'Upload artifacts'
uses: actions/upload-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
mkdir artifacts
cp Fabric/build/libs/*.jar artifacts
cp Forge/build/libs/*.jar artifacts
cp NeoForge/build/libs/*.jar artifacts
- name: 'Upload artifacts'
uses: actions/upload-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
mkdir artifacts
cp Fabric/build/libs/*.jar artifacts
cp Forge/build/libs/*.jar artifacts
cp NeoForge/build/libs/*.jar artifacts
- name: 'Upload artifacts'
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {

mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.20.3:$mappings_version@zip") // Waiting for 1.20.4
parchment("org.parchmentmc.data:parchment-$mc_version:$mappings_version@zip")
}

modImplementation "net.fabricmc:fabric-loader:$loader_version"
Expand Down
7 changes: 4 additions & 3 deletions Fabric/src/main/java/hantonik/fbp/FancyBlockParticles.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hantonik.fbp;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.logging.LogUtils;
import hantonik.fbp.config.FBPConfig;
import hantonik.fbp.init.FBPKeyMappings;
Expand All @@ -14,7 +15,7 @@
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleRenderType;
Expand Down Expand Up @@ -88,8 +89,8 @@ private void postClientTick(Minecraft client) {
FancyBlockParticles.CONFIG.setFrozen(!FancyBlockParticles.CONFIG.isFrozen());
}

public void onRenderHud(GuiGraphics graphics, float partialTick) {
public void onRenderHud(PoseStack stack, float partialTick) {
if (FancyBlockParticles.CONFIG.isEnabled() && FancyBlockParticles.CONFIG.isFrozen())
graphics.drawCenteredString(Minecraft.getInstance().font, Component.translatable("screen.fbp.freeze"), graphics.guiWidth() / 2, 5, 0x0080FF);
GuiComponent.drawCenteredString(stack, Minecraft.getInstance().font, Component.translatable("screen.fbp.freeze"), Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2, 5, 0x0080FF);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void destroy(BlockPos pos, BlockState state, CallbackInfo callback) {

callback.cancel();

if (!state.isAir() && state.shouldSpawnTerrainParticles()) {
if (!state.isAir() && state.shouldSpawnParticlesOnBreak()) {
var shape = state.getShape(this.level, pos);
var sprite = Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getParticleIcon(state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ public void render(VertexConsumer buffer, Camera info, float partialTicks) {
var v0 = 0.0F;

if (!FancyBlockParticles.CONFIG.isCartoonMode()) {
u0 = this.sprite.getU(this.uo / 4.0F);
v0 = this.sprite.getV(this.vo / 4.0F);
u0 = this.sprite.getU(this.uo / 4.0F * 16.0F);
v0 = this.sprite.getV(this.vo / 4.0F * 16.0F);
}

var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F);
var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F * 16.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F * 16.0F);

var posX = (float) (Mth.lerp(partialTicks, this.xo, this.x) - info.getPosition().x);
var posY = (float) (Mth.lerp(partialTicks, this.yo, this.y) - info.getPosition().y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ public void render(VertexConsumer buffer, Camera info, float partialTicks) {
var v0 = 0.0F;

if (!FancyBlockParticles.CONFIG.isCartoonMode()) {
u0 = this.sprite.getU(this.uo / 4.0F);
v0 = this.sprite.getV(this.vo / 4.0F);
u0 = this.sprite.getU(this.uo / 4.0F * 16.0F);
v0 = this.sprite.getV(this.vo / 4.0F * 16.0F);
}

var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F);
var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F * 16.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F * 16.0F);

var posX = (float) (Mth.lerp(partialTicks, this.xo, this.x) - info.getPosition().x);
var posY = (float) (Mth.lerp(partialTicks, this.yo, this.y) - info.getPosition().y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,12 @@ public void render(VertexConsumer buffer, Camera info, float partialTicks) {
var v0 = 0.0F;

if (!FancyBlockParticles.CONFIG.isCartoonMode()) {
u0 = this.sprite.getU(this.uo / 4.0F);
v0 = this.sprite.getV(this.vo / 4.0F);
u0 = this.sprite.getU(this.uo / 4.0F * 16.0F);
v0 = this.sprite.getV(this.vo / 4.0F * 16.0F);
}

var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F);
var u1 = this.sprite.getU((this.uo + 1.0F) / 4.0F * 16.0F);
var v1 = this.sprite.getV((this.vo + 1.0F) / 4.0F * 16.0F);

var posX = (float) (Mth.lerp(partialTicks, this.xo, this.x) - info.getPosition().x);
var posY = (float) (Mth.lerp(partialTicks, this.yo, this.y) - info.getPosition().y);
Expand Down
48 changes: 31 additions & 17 deletions Fabric/src/main/java/hantonik/fbp/screen/FBPBlacklistScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hantonik.fbp.screen;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import hantonik.fbp.FancyBlockParticles;
import hantonik.fbp.init.FBPKeyMappings;
import hantonik.fbp.screen.widget.button.FBPBlacklistButton;
Expand All @@ -8,7 +10,6 @@
import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -95,46 +96,59 @@ public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
}

@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
public void render(PoseStack stack, int mouseX, int mouseY, float partialTick) {
this.renderBackground(stack);

var x = this.width / 2;
var y = this.height / 2;

mouseX = Mth.clamp(mouseX, this.animationButton.get().getX() + 30, this.particleButton.get().getX() + 30);
mouseY = y + 35;

graphics.blit(WIDGETS, this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 - 10, 0, 0, 195, 20);
graphics.drawCenteredString(this.font, Component.literal("<").withStyle(this.animationButton.get().active ? ChatFormatting.GREEN : ChatFormatting.RED).append(" ").append(Component.literal(">").withStyle(this.particleButton.get().active ? ChatFormatting.GREEN : ChatFormatting.RED)), this.animationButton.get().getX() + 30 + 100, this.animationButton.get().getY() + 30 - 4, 0);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();

RenderSystem.setShaderTexture(0, WIDGETS);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

blit(stack, this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 - 10, 0, 0, 195, 20);
drawCenteredString(stack, this.font, Component.literal("<").withStyle(this.animationButton.get().active ? ChatFormatting.GREEN : ChatFormatting.RED).append(" ").append(Component.literal(">").withStyle(this.particleButton.get().active ? ChatFormatting.GREEN : ChatFormatting.RED)), this.animationButton.get().getX() + 30 + 100, this.animationButton.get().getY() + 30 - 4, 0);

graphics.drawCenteredString(this.font, this.title.copy().withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), x, 10, 0);
drawCenteredString(stack, this.font, this.title.copy().withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), x, 10, 0);

var displayId = BuiltInRegistries.ITEM.getKey(this.displayStack.getItem());
graphics.drawCenteredString(this.font, Component.literal(displayId.getNamespace()).withStyle(ChatFormatting.GOLD).append(Component.literal(":").withStyle(ChatFormatting.RED)).append(Component.literal(displayId.getPath()).withStyle(ChatFormatting.GREEN)).withStyle(ChatFormatting.BOLD), x, y - 19, 0);
drawCenteredString(stack, this.font, Component.literal(displayId.getNamespace()).withStyle(ChatFormatting.GOLD).append(Component.literal(":").withStyle(ChatFormatting.RED)).append(Component.literal(displayId.getPath()).withStyle(ChatFormatting.GREEN)).withStyle(ChatFormatting.BOLD), x, y - 19, 0);

if (this.animationButton.get().isMouseOver(mouseX, mouseY)) {
graphics.drawCenteredString(this.font, Component.translatable("tooltip.fbp.animation").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 - 42, 0);
drawCenteredString(stack, this.font, Component.translatable("tooltip.fbp.animation").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 - 42, 0);

graphics.drawCenteredString(this.font, this.animationButton.get().isBlackListed() ? Component.translatable("tooltip.fbp.remove").withStyle(ChatFormatting.BOLD, ChatFormatting.RED) : Component.translatable("tooltip.fbp.add").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 + 35, 0);
drawCenteredString(stack, this.font, this.animationButton.get().isBlackListed() ? Component.translatable("tooltip.fbp.remove").withStyle(ChatFormatting.BOLD, ChatFormatting.RED) : Component.translatable("tooltip.fbp.add").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.animationButton.get().getX() + 30, this.animationButton.get().getY() + 30 + 35, 0);
}

if (this.particleButton.get().isMouseOver(mouseX, mouseY)) {
graphics.drawCenteredString(this.font, Component.translatable("tooltip.fbp.particles").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.particleButton.get().getX() + 30, this.particleButton.get().getY() + 30 - 42, 0);
drawCenteredString(stack, this.font, Component.translatable("tooltip.fbp.particles").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.particleButton.get().getX() + 30, this.particleButton.get().getY() + 30 - 42, 0);

graphics.drawCenteredString(this.font, this.particleButton.get().isBlackListed() ? Component.translatable("tooltip.fbp.remove").withStyle(ChatFormatting.BOLD, ChatFormatting.RED) : Component.translatable("tooltip.fbp.add").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.particleButton.get().getX() + 30, this.particleButton.get().getY() + 30 + 35, 0);
drawCenteredString(stack, this.font, this.particleButton.get().isBlackListed() ? Component.translatable("tooltip.fbp.remove").withStyle(ChatFormatting.BOLD, ChatFormatting.RED) : Component.translatable("tooltip.fbp.add").withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN), this.particleButton.get().getX() + 30, this.particleButton.get().getY() + 30 + 35, 0);
}

graphics.pose().pushPose();
stack.pushPose();

graphics.pose().translate(x - 32, y - 32 - 57.0, 0.0F);
graphics.pose().scale(4.0F, 4.0F, 1.0F);
stack.translate(x - 32, y - 32 - 57.0, 0.0F);
stack.scale(4.0F, 4.0F, 1.0F);

graphics.renderItem(this.displayStack, 0, 0);
this.itemRenderer.renderGuiItem(stack, this.displayStack, 0, 0);

graphics.pose().popPose();
stack.popPose();

super.render(graphics, mouseX, mouseY, partialTick);
super.render(stack, mouseX, mouseY, partialTick);

var mouseOver = this.animationButton.get().isMouseOver(mouseX, mouseY) ? this.animationButton.get() : (this.particleButton.get().isMouseOver(mouseX, mouseY) ? this.particleButton.get() : null);
graphics.blit(WIDGETS, mouseX - 20 / 2, mouseY - 20 / 2, mouseOver != null && !mouseOver.active ? 256 - 20 * 2 : 256 - 20, 256 - 20, 20, 20);

RenderSystem.setShaderTexture(0, WIDGETS);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

blit(stack, mouseX - 20 / 2, mouseY - 20 / 2, mouseOver != null && !mouseOver.active ? 256 - 20 * 2 : 256 - 20, 256 - 20, 20, 20);
}

@Override
Expand Down
26 changes: 18 additions & 8 deletions Fabric/src/main/java/hantonik/fbp/screen/FBPOptionsScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hantonik.fbp.screen;

import com.mojang.blaze3d.vertex.PoseStack;
import hantonik.fbp.FancyBlockParticles;
import hantonik.fbp.config.FBPConfig;
import hantonik.fbp.init.FBPKeyMappings;
Expand All @@ -10,8 +11,10 @@
import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.StringWidget;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.layouts.FrameLayout;
import net.minecraft.client.gui.layouts.GridLayout;
import net.minecraft.client.gui.layouts.SpacerElement;
Expand All @@ -27,8 +30,8 @@

@Environment(EnvType.CLIENT)
public class FBPOptionsScreen extends Screen {
private static final WidgetSprites LOGO_SPRITES = new WidgetSprites(new ResourceLocation(FancyBlockParticles.MOD_ID, "logo"), new ResourceLocation(FancyBlockParticles.MOD_ID, "logo_highlighted"));
private static final WidgetSprites REPORT_SPRITES = new WidgetSprites(new ResourceLocation(FancyBlockParticles.MOD_ID, "report"), new ResourceLocation(FancyBlockParticles.MOD_ID, "report_highlighted"));
private static final ResourceLocation LOGO_TEXTURE = new ResourceLocation(FancyBlockParticles.MOD_ID, "textures/gui/logo.png");
private static final ResourceLocation REPORT_TEXTURE = new ResourceLocation(FancyBlockParticles.MOD_ID, "textures/gui/report.png");

private final FBPConfig config;

Expand All @@ -44,8 +47,8 @@ public FBPOptionsScreen() {

@Override
protected void init() {
this.addRenderableWidget(new ImageButton(10, 10, 25, 25, LOGO_SPRITES, button -> this.handleComponentClicked(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.curseforge.com/minecraft/mc-mods/fbp-renewed"))))).setTooltip(Tooltip.create(Component.translatable("button.fbp.homepage")));
this.addRenderableWidget(new ImageButton(this.width - 10 - 25, 10, 25, 25, REPORT_SPRITES, button -> this.handleComponentClicked(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/Hantonik/FancyBlockParticles/issues"))))).setTooltip(Tooltip.create(Component.translatable("button.fbp.report")));
this.addRenderableWidget(new ImageButton(10, 10, 25, 25, 0, 0, LOGO_TEXTURE, button -> this.handleComponentClicked(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.curseforge.com/minecraft/mc-mods/fbp-renewed"))))).setTooltip(Tooltip.create(Component.translatable("button.fbp.homepage")));
this.addRenderableWidget(new ImageButton(this.width - 10 - 25, 10, 25, 25, 0, 0, REPORT_TEXTURE, button -> this.handleComponentClicked(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/Hantonik/FancyBlockParticles/issues"))))).setTooltip(Tooltip.create(Component.translatable("button.fbp.report")));

var version = Component.translatable("text.fbp.version", SharedConstants.getCurrentVersion().getName() + "-" + FancyBlockParticles.MOD_VERSION);
this.addRenderableWidget(new StringWidget(5, this.height - 5 - 9, this.font.width(version), 9, version, this.font));
Expand Down Expand Up @@ -256,8 +259,15 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
}

@Override
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
this.renderDirtBackground(graphics);
public void render(PoseStack stack, int mouseX, int mouseY, float partialTick) {
this.renderBackground(stack);

super.render(stack, mouseX, mouseY, partialTick);
}

@Override
public void renderBackground(PoseStack stack) {
this.renderDirtBackground(stack);
}

private void onDone() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package hantonik.fbp.screen.widget.button;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import hantonik.fbp.FancyBlockParticles;
import lombok.Getter;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -23,13 +23,16 @@ public FBPBlacklistButton(int x, int y, boolean particle, boolean isBlacklisted,
}

@Override
protected void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
public void renderWidget(PoseStack stack, int mouseX, int mouseY, float partialTick) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();

RenderSystem.setShaderTexture(0, WIDGETS);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

graphics.blit(WIDGETS, this.getX(), this.getY(), this.isBlackListed ? 60 : 0, 196, 60, 60);
graphics.blit(WIDGETS, (int) (this.getX() + this.width / 2.0F - 22.5F + (this.particle ? 0.0F : 2.0F)), (int) (this.getY() + this.height / 2 - 22.5F), 256 - 45, this.particle ? 45 : 0, 45, 45);
blit(stack, this.getX(), this.getY(), this.isBlackListed ? 60 : 0, 196, 60, 60);
blit(stack, (int) (this.getX() + this.width / 2.0F - 22.5F + (this.particle ? 0.0F : 2.0F)), (int) (this.getY() + this.height / 2 - 22.5F), 256 - 45, this.particle ? 45 : 0, 45, 45);
}

@Override
Expand Down
Loading

0 comments on commit f588f1e

Please sign in to comment.