mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-16 05:55:09 +01:00
VisualOverhaul 5.1.0 - Code overhaul!
- Update to 1.20.4 - Switch Forge version to NeoForge - Update resourcepacks & add round relic disc (thanks to @SuperNoobYT) - Furnaces will now show results when finished (closes #61) - Fix crash related to sound events (closes #60, #52) - Fix crash related to button icons (closes #59, #55, #54, likely #49) - Fix log spam when mod is only present on server (closes #33) - Fix jukeboxes staying powered after playback has finished (closes #53)
This commit is contained in:
@@ -17,17 +17,3 @@ dependencies {
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
//modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,12 @@ public class IconicButtons {
|
||||
private String buttonId;
|
||||
private Text prevText;
|
||||
private Identifier iconId;
|
||||
public IconicButtons(ClickableWidget widget) {
|
||||
init(widget);
|
||||
}
|
||||
public IconicButtons() {}
|
||||
public void init(ClickableWidget widget) {
|
||||
if (widget == null || widget.getMessage() == null || widget.getMessage().getContent() == null) return;
|
||||
prevText = widget.getMessage();
|
||||
buttonId = (widget.getMessage().getContent() instanceof TranslatableTextContent translatableTextContent) ? translatableTextContent.getKey().toLowerCase() : "";
|
||||
if (VOConfig.buttonIcons && !buttonId.equals("")) {
|
||||
if (VOConfig.buttonIcons && !buttonId.isEmpty()) {
|
||||
if (VOConfig.debug) System.out.println(buttonId);
|
||||
iconId = Identifier.tryParse("iconic:textures/gui/icons/" + buttonId.toLowerCase()+".png");
|
||||
if (buttonId.endsWith(".midnightconfig.title"))
|
||||
@@ -55,7 +54,7 @@ public class IconicButtons {
|
||||
}
|
||||
}
|
||||
public void renderIcons(DrawContext context, ClickableWidget widget, float alpha) {
|
||||
if (widget.getMessage() == null) return;
|
||||
if (widget.getMessage() == null || widget.getWidth() <= 20) return;
|
||||
if (prevText != widget.getMessage()) init(widget);
|
||||
if (VOConfig.buttonIcons && !buttonId.equals("") && iconId != null) {
|
||||
int scaledWidth = client.getWindow().getScaledWidth();
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
package eu.midnightdust.visualoverhaul;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VisualOverhaul {
|
||||
public static final String MOD_ID = "visualoverhaul";
|
||||
public static final List<UUID> playersWithMod = Lists.newArrayList();
|
||||
public static final Map<BlockPos, ItemStack> jukeboxItems = new HashMap<>();
|
||||
|
||||
public static final Identifier HELLO_PACKET = new Identifier(MOD_ID, "hello");
|
||||
public static final Identifier UPDATE_POTION_BOTTLES = new Identifier(MOD_ID, "brewingstand");
|
||||
public static final Identifier UPDATE_RECORD = new Identifier(MOD_ID, "record");
|
||||
public static final Identifier UPDATE_FURNACE_ITEMS = new Identifier(MOD_ID, "furnace");
|
||||
|
||||
@@ -38,11 +38,12 @@ public class FurnaceBlockEntityRenderer<E extends AbstractFurnaceBlockEntity> im
|
||||
if (VOConfig.furnace && blockEntity != null) {
|
||||
BlockState blockState = blockEntity.getCachedState();
|
||||
int lightAtBlock = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(blockEntity.getWorld()), blockEntity.getPos().offset(blockState.get(AbstractFurnaceBlock.FACING)));
|
||||
ItemStack item1 = blockEntity.getStack(0);
|
||||
ItemStack item2 = blockEntity.getStack(1);
|
||||
ItemStack input = blockEntity.getStack(0);
|
||||
ItemStack fuel = blockEntity.getStack(1);
|
||||
ItemStack output = blockEntity.getStack(2);
|
||||
float angle = (blockState.get(AbstractFurnaceBlock.FACING)).asRotation();
|
||||
|
||||
if(!item1.isEmpty()) {
|
||||
if(!input.isEmpty() || !output.isEmpty()) {
|
||||
matrices.push();
|
||||
|
||||
matrices.translate(0.5f, 0.58f, 0.5f);
|
||||
@@ -52,12 +53,12 @@ public class FurnaceBlockEntityRenderer<E extends AbstractFurnaceBlockEntity> im
|
||||
matrices.multiply(new Quaternionf(new AxisAngle4f(Math.toRadians(angle * 3 + 180), 0, 1, 0)));
|
||||
matrices.translate(0.0f, 0.0f, -0.4f);
|
||||
matrices.multiply(degrees90x);
|
||||
MinecraftClient.getInstance().getItemRenderer().renderItem(item1, ModelTransformationMode.GROUND, lightAtBlock, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0);
|
||||
MinecraftClient.getInstance().getItemRenderer().renderItem(input.isEmpty() ? output : input, ModelTransformationMode.GROUND, lightAtBlock, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0);
|
||||
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
if (!item2.isEmpty() && !item2.isIn(ItemTags.LOGS_THAT_BURN) && !item2.isIn(ItemTags.PLANKS)) {
|
||||
if (!fuel.isEmpty() && !fuel.isIn(ItemTags.LOGS_THAT_BURN) && !fuel.isIn(ItemTags.PLANKS)) {
|
||||
matrices.push();
|
||||
|
||||
matrices.translate(0.5f, 0.08f, 0.5f);
|
||||
@@ -67,13 +68,13 @@ public class FurnaceBlockEntityRenderer<E extends AbstractFurnaceBlockEntity> im
|
||||
matrices.multiply(new Quaternionf(new AxisAngle4f(Math.toRadians(angle * 3 + 180), 0, 1, 0)));
|
||||
matrices.translate(0.0f, 0.0f, -0.4f);
|
||||
matrices.multiply(degrees90x);
|
||||
MinecraftClient.getInstance().getItemRenderer().renderItem(item2, ModelTransformationMode.GROUND, lightAtBlock, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0);
|
||||
MinecraftClient.getInstance().getItemRenderer().renderItem(fuel, ModelTransformationMode.GROUND, lightAtBlock, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
else if (!item2.isEmpty()) {
|
||||
else if (!fuel.isEmpty()) {
|
||||
matrices.push();
|
||||
BlockState state = Block.getBlockFromItem(item2.getItem()).getDefaultState();
|
||||
BlockState state = Block.getBlockFromItem(fuel.getItem()).getDefaultState();
|
||||
Sprite texture = MinecraftClient.getInstance().getBlockRenderManager().getModel(state).getParticleSprite();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(spriteToTexture(texture)));
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.joml.Quaternionf;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.jukeboxItems;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class JukeboxBlockEntityRenderer implements BlockEntityRenderer<JukeboxBlockEntity> {
|
||||
private ItemStack record;
|
||||
@@ -43,8 +45,8 @@ public class JukeboxBlockEntityRenderer implements BlockEntityRenderer<JukeboxBl
|
||||
int lightAbove = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(blockEntity.getWorld()), blockEntity.getPos().up());
|
||||
|
||||
// Tries to get the disc using the serverside method
|
||||
if (blockEntity.getStack() != ItemStack.EMPTY) {
|
||||
record = blockEntity.getStack().copy();
|
||||
if (jukeboxItems.containsKey(blockEntity.getPos()) && !jukeboxItems.get(blockEntity.getPos()).isEmpty()) {
|
||||
record = jukeboxItems.get(blockEntity.getPos()).copy();
|
||||
}
|
||||
// Else gets the record sound played at the position of the jukebox //
|
||||
else if (SoundTest.getSound(blockEntity.getPos()) != null) {
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package eu.midnightdust.visualoverhaul.mixin;
|
||||
|
||||
import net.minecraft.block.entity.JukeboxBlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(JukeboxBlockEntity.class)
|
||||
public interface JukeboxBlockEntityAccessor {
|
||||
@Accessor @Final
|
||||
DefaultedList<ItemStack> getInventory();
|
||||
}
|
||||
@@ -13,17 +13,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PressableWidget.class)
|
||||
public abstract class MixinPressableWidget extends ClickableWidget {
|
||||
@Unique IconicButtons iconicButtons;
|
||||
@Unique IconicButtons visualoverhaul$iconicButtons;
|
||||
public MixinPressableWidget(int x, int y, int width, int height, Text message) {
|
||||
super(x, y, width, height, message);
|
||||
}
|
||||
@Inject(at = @At("TAIL"), method = "<init>")
|
||||
private void iconic$onInitButton(int i, int j, int k, int l, Text text, CallbackInfo ci) {
|
||||
iconicButtons = new IconicButtons(this);
|
||||
visualoverhaul$iconicButtons = new IconicButtons();
|
||||
visualoverhaul$iconicButtons.init(this);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/PressableWidget;drawMessage(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;I)V", shift = At.Shift.BEFORE), method = "renderButton")
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/PressableWidget;drawMessage(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;I)V", shift = At.Shift.BEFORE), method = "renderWidget")
|
||||
private void iconic$onRenderButton(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
iconicButtons.renderIcons(context, this, this.alpha);
|
||||
visualoverhaul$iconicButtons.renderIcons(context, this, this.alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,17 +13,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(SliderWidget.class)
|
||||
public abstract class MixinSliderWidget extends ClickableWidget {
|
||||
@Unique IconicButtons iconicButtons;
|
||||
@Unique IconicButtons visualoverhaul$iconicButtons;
|
||||
public MixinSliderWidget(int x, int y, int width, int height, Text message) {
|
||||
super(x, y, width, height, message);
|
||||
}
|
||||
@Inject(at = @At("TAIL"), method = "<init>")
|
||||
private void iconic$onInitButton(int x, int y, int width, int height, Text text, double value, CallbackInfo ci) {
|
||||
iconicButtons = new IconicButtons(this);
|
||||
visualoverhaul$iconicButtons = new IconicButtons();
|
||||
visualoverhaul$iconicButtons.init(this);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/SliderWidget;drawScrollableText(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;II)V", shift = At.Shift.BEFORE), method = "renderButton")
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/SliderWidget;drawScrollableText(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;II)V", shift = At.Shift.BEFORE), method = "renderWidget")
|
||||
private void iconic$onRenderButton(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
iconicButtons.renderIcons(context, this, this.alpha);
|
||||
visualoverhaul$iconicButtons.renderIcons(context, this, this.alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -16,13 +17,16 @@ public abstract class MixinSoundSystem {
|
||||
|
||||
@Shadow private boolean started;
|
||||
|
||||
private BlockPos jukeboxPos;
|
||||
@Unique
|
||||
private BlockPos visualoverhaul$jukeboxPos;
|
||||
|
||||
@Inject(at = @At("TAIL"),method = "play(Lnet/minecraft/client/sound/SoundInstance;)V")
|
||||
public void vo$onPlayRecordSound(SoundInstance soundInstance, CallbackInfo ci) {
|
||||
if (soundInstance.getCategory().equals(SoundCategory.RECORDS) && this.started) {
|
||||
jukeboxPos = BlockPos.ofFloored(Math.floor(soundInstance.getX()), Math.floor(soundInstance.getY()), Math.floor(soundInstance.getZ()));
|
||||
SoundTest.soundPos.put(jukeboxPos, soundInstance.getId());
|
||||
if (soundInstance != null) {
|
||||
if (soundInstance.getCategory().equals(SoundCategory.RECORDS) && this.started) {
|
||||
visualoverhaul$jukeboxPos = BlockPos.ofFloored(Math.floor(soundInstance.getX()), Math.floor(soundInstance.getY()), Math.floor(soundInstance.getZ()));
|
||||
SoundTest.soundPos.put(visualoverhaul$jukeboxPos, soundInstance.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +34,9 @@ public abstract class MixinSoundSystem {
|
||||
public void vo$onStopRecordSound(SoundInstance soundInstance, CallbackInfo ci) {
|
||||
if (soundInstance != null) {
|
||||
if (soundInstance.getCategory().equals(SoundCategory.RECORDS)) {
|
||||
jukeboxPos = BlockPos.ofFloored(Math.floor(soundInstance.getX()), Math.floor(soundInstance.getY()), Math.floor(soundInstance.getZ()));
|
||||
if (SoundTest.soundPos.containsKey(jukeboxPos)) {
|
||||
SoundTest.soundPos.remove(jukeboxPos, soundInstance.getId());
|
||||
visualoverhaul$jukeboxPos = BlockPos.ofFloored(Math.floor(soundInstance.getX()), Math.floor(soundInstance.getY()), Math.floor(soundInstance.getZ()));
|
||||
if (SoundTest.soundPos.containsKey(visualoverhaul$jukeboxPos)) {
|
||||
SoundTest.soundPos.remove(visualoverhaul$jukeboxPos, soundInstance.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 99],
|
||||
"description": "§2Makes the water bucket respect biome colors"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 99],
|
||||
"description": "§2Changes the model of the furnace to be 3D"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 99],
|
||||
"description": "§2Removes the bottles from the brewing stand"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 99],
|
||||
"description": "§2Makes the spinning discs on Jukeboxes round"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
"MixinBlastFurnaceBlock",
|
||||
"MixinPressableWidget",
|
||||
"MixinSliderWidget",
|
||||
"TextureManagerAccessor",
|
||||
"JukeboxBlockEntityAccessor"
|
||||
"TextureManagerAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user