mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-13 04:45:10 +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:
18
build.gradle
18
build.gradle
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -46,6 +47,21 @@ allprojects {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
}
|
||||
ext {
|
||||
releaseChangelog = {
|
||||
def changes = new StringBuilder()
|
||||
changes << "## VisualOverhaul v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/VisualOverhaul/commits/)"
|
||||
def proc = "git log --max-count=1 --pretty=format:%s".execute()
|
||||
proc.in.eachLine { line ->
|
||||
def processedLine = line.toString()
|
||||
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
|
||||
changes << "\n- ${processedLine.capitalize()}"
|
||||
}
|
||||
}
|
||||
proc.waitFor()
|
||||
return changes.toString()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -44,21 +45,18 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
shadowJar {
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
injectAccessWidener = true
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
@@ -73,16 +71,42 @@ components.java {
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "VisualOverhaul v$project.version - Fabric $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["fabric","quilt"]
|
||||
mainPublication remapJar
|
||||
relations {
|
||||
depends {
|
||||
curseforge = "fabric-api"
|
||||
modrinth = "fabric-api"
|
||||
}
|
||||
includes {
|
||||
curseforge = "midnightlib"
|
||||
modrinth = "midnightlib"
|
||||
}
|
||||
}
|
||||
|
||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||
if (CURSEFORGE_TOKEN != null) {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 17", project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||
if (MODRINTH_TOKEN != null) {
|
||||
modrinth {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,11 @@ import eu.midnightdust.visualoverhaul.block.renderer.BrewingStandBlockEntityRend
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.FurnaceBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.JukeboxBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import eu.midnightdust.visualoverhaul.mixin.JukeboxBlockEntityAccessor;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
|
||||
@@ -23,16 +24,14 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.BrewingStandBlockEntity;
|
||||
import net.minecraft.block.entity.JukeboxBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.world.BiomeColors;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
|
||||
import net.minecraft.client.texture.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.potion.PotionUtil;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.registry.Registries;
|
||||
@@ -42,10 +41,6 @@ import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.*;
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaulClient.JukeBoxTop;
|
||||
@@ -87,16 +82,14 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
||||
(client, handler, attachedData, packetSender) -> {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
DefaultedList<ItemStack> inv = DefaultedList.ofSize(5, ItemStack.EMPTY);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof BrewingStandBlockEntity blockEntity) {
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
blockEntity.setStack(3, inv.get(3));
|
||||
blockEntity.setStack(4, inv.get(4));
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
blockEntity.setStack(i, inv.get(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -105,23 +98,21 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
ItemStack record = attachedData.readItemStack();
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof JukeboxBlockEntity blockEntity) {
|
||||
((JukeboxBlockEntityAccessor)blockEntity).getInventory().set(0, record);
|
||||
}
|
||||
jukeboxItems.put(pos, record);
|
||||
});
|
||||
});
|
||||
ClientPlayNetworking.registerGlobalReceiver(UPDATE_FURNACE_ITEMS,
|
||||
(client, handler, attachedData, packetSender) -> {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
DefaultedList<ItemStack> inv = DefaultedList.ofSize(3, ItemStack.EMPTY);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof AbstractFurnaceBlockEntity blockEntity) {
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
blockEntity.setStack(i, inv.get(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -133,6 +124,13 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(MOD_ID,"coloredwaterbucket"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(MOD_ID,"rounddiscs"), modContainer, ResourcePackActivationType.ALWAYS_ENABLED);
|
||||
});
|
||||
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
||||
if (client.player != null) {
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeUuid(client.player.getUuid());
|
||||
sender.sendPacket(HELLO_PACKET, passedData);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Biome-colored Items
|
||||
@@ -158,7 +156,7 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.TROPICAL_FISH_BUCKET);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.SALMON_BUCKET);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.GRASS_BLOCK);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.GRASS);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.SHORT_GRASS);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.TALL_GRASS);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.FERN);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.LARGE_FERN);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package eu.midnightdust.visualoverhaul.fabric;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.networking.v1.*;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.HELLO_PACKET;
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.playersWithMod;
|
||||
|
||||
public class VisualOverhaulFabric implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ServerPlayNetworking.registerGlobalReceiver(HELLO_PACKET, (server, player, handler, buf, responseSender) -> playersWithMod.add(player.getUuid()));
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> playersWithMod.remove(handler.getPlayer().getUuid()));
|
||||
};
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
@@ -24,8 +25,10 @@ import java.util.stream.Stream;
|
||||
@Mixin(AbstractFurnaceBlockEntity.class)
|
||||
public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerBlockEntity {
|
||||
|
||||
private static boolean invUpdate = true;
|
||||
private static int playerUpdate = -1;
|
||||
@Unique
|
||||
private static boolean visualoverhaul$invUpdate = true;
|
||||
@Unique
|
||||
private static int visualoverhaul$playerUpdate = -1;
|
||||
|
||||
|
||||
protected MixinAbstractFurnaceBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
@@ -35,7 +38,7 @@ public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerB
|
||||
@Inject(at = @At("TAIL"), method = "tick")
|
||||
private static void tick(World world, BlockPos pos, BlockState state, AbstractFurnaceBlockEntity blockEntity, CallbackInfo ci) {
|
||||
if (world.getBlockState(pos).hasBlockEntity()) {
|
||||
if (!world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
|
||||
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
@@ -43,15 +46,19 @@ public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerB
|
||||
passedData.writeItemStack(blockEntity.getStack(1));
|
||||
passedData.writeItemStack(blockEntity.getStack(2));
|
||||
|
||||
watchingPlayers.forEach(player -> ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData));
|
||||
invUpdate = false;
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData);
|
||||
}
|
||||
});
|
||||
visualoverhaul$invUpdate = false;
|
||||
}
|
||||
playerUpdate = world.getPlayers().size();
|
||||
visualoverhaul$playerUpdate = world.getPlayers().size();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "getStack")
|
||||
public void getStack(int slot, CallbackInfoReturnable<ItemStack> cir) {
|
||||
invUpdate = true;
|
||||
visualoverhaul$invUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
@@ -24,8 +25,10 @@ import java.util.stream.Stream;
|
||||
@Mixin(BrewingStandBlockEntity.class)
|
||||
public abstract class MixinBrewingStandBlockEntity extends LockableContainerBlockEntity {
|
||||
|
||||
private static boolean invUpdate = true;
|
||||
private static int playerUpdate = -1;
|
||||
@Unique
|
||||
private static boolean visualoverhaul$invUpdate = true;
|
||||
@Unique
|
||||
private static int visualoverhaul$playerUpdate = -1;
|
||||
|
||||
protected MixinBrewingStandBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
@@ -33,7 +36,7 @@ public abstract class MixinBrewingStandBlockEntity extends LockableContainerBloc
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "tick")
|
||||
private static void tick(World world, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity, CallbackInfo ci) {
|
||||
if (!world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
|
||||
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
@@ -43,14 +46,18 @@ public abstract class MixinBrewingStandBlockEntity extends LockableContainerBloc
|
||||
passedData.writeItemStack(blockEntity.getStack(3));
|
||||
passedData.writeItemStack(blockEntity.getStack(4));
|
||||
|
||||
watchingPlayers.forEach(player -> ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_POTION_BOTTLES, passedData));
|
||||
invUpdate = false;
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_POTION_BOTTLES, passedData);
|
||||
}
|
||||
});
|
||||
visualoverhaul$invUpdate = false;
|
||||
}
|
||||
playerUpdate = world.getPlayers().size();
|
||||
visualoverhaul$playerUpdate = world.getPlayers().size();
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "getStack")
|
||||
public void getStack(int slot, CallbackInfoReturnable<ItemStack> cir) {
|
||||
invUpdate = true;
|
||||
visualoverhaul$invUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,17 +37,21 @@ public abstract class MixinJukeboxBlock extends BlockWithEntity {
|
||||
|
||||
@Nullable
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
|
||||
return world.isClient() ? null : checkType(type, BlockEntityType.JUKEBOX, MixinJukeboxBlock::tick);
|
||||
return world.isClient() ? null : validateTicker(type, BlockEntityType.JUKEBOX, MixinJukeboxBlock::visualoverhaul$tick);
|
||||
}
|
||||
@Unique
|
||||
private static void tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
|
||||
private static void visualoverhaul$tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
|
||||
if (!world.isClient && (JukeboxPacketUpdate.invUpdate || world.getPlayers().size() == JukeboxPacketUpdate.playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
passedData.writeItemStack(blockEntity.getStack());
|
||||
|
||||
watchingPlayers.forEach(player -> ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_RECORD, passedData));
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
ServerPlayNetworking.send(player, VisualOverhaul.UPDATE_RECORD, passedData);
|
||||
}
|
||||
});
|
||||
JukeboxPacketUpdate.invUpdate = false;
|
||||
}
|
||||
JukeboxPacketUpdate.playerUpdate = world.getPlayers().size();
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"eu.midnightdust.visualoverhaul.fabric.VisualOverhaulClientFabric"
|
||||
],
|
||||
"main": [
|
||||
"eu.midnightdust.visualoverhaul.fabric.VisualOverhaulFabric"
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
forge()
|
||||
}
|
||||
|
||||
loom {
|
||||
forge {
|
||||
mixinConfig "visualoverhaul.mixins.json"
|
||||
mixinConfig "visualoverhaul-forge.mixins.json"
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven { url "https://api.modrinth.com/maven" }
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
archivesBaseName = rootProject.archives_base_name + "-forge"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "fabric.mod.json"
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
classifier "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
classifier null
|
||||
}
|
||||
|
||||
jar {
|
||||
classifier "dev"
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenForge(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.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.
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
loom.platform=forge
|
||||
@@ -1,15 +0,0 @@
|
||||
package eu.midnightdust.visualoverhaul.forge;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.MOD_ID;
|
||||
|
||||
@Mod(MOD_ID)
|
||||
public class VisualOverhaulForge {
|
||||
|
||||
public VisualOverhaulForge() {
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> VisualOverhaulClientForge::initClient);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,24 @@
|
||||
org.gradle.jvmargs=-Xmx4096M
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
|
||||
minecraft_version=1.20
|
||||
yarn_mappings=1.20+build.1
|
||||
enabled_platforms=quilt,fabric,forge
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=visualoverhaul
|
||||
mod_version=5.0.1
|
||||
mod_version=5.1.0
|
||||
maven_group=eu.midnightdust
|
||||
release_type=release
|
||||
curseforge_id=432008
|
||||
modrinth_id=YQnwl5Vv
|
||||
|
||||
architectury_version=9.0.7
|
||||
midnightlib_version=1.4.1
|
||||
midnightlib_version=1.5.3
|
||||
phonos_version=0.3.0+1.19.2
|
||||
|
||||
fabric_loader_version=0.14.21
|
||||
fabric_api_version=0.83.0+1.20
|
||||
fabric_loader_version=0.15.7
|
||||
fabric_api_version=0.96.3+1.20.4
|
||||
|
||||
forge_version=1.20-46.0.13
|
||||
neoforge_version=20.4.170
|
||||
architectury_version=11.0.12
|
||||
|
||||
quilt_loader_version=0.19.0-beta.18
|
||||
quilt_fabric_api_version=7.0.1+0.83.0-1.20
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
109
neoforge/build.gradle
Normal file
109
neoforge/build.gradle
Normal file
@@ -0,0 +1,109 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "me.shedaniel.unified-publishing"
|
||||
}
|
||||
|
||||
architectury {
|
||||
injectInjectables = false
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
}
|
||||
|
||||
loom {}
|
||||
repositories {
|
||||
maven { url "https://api.modrinth.com/maven" }
|
||||
maven {url "https://maven.neoforged.net/releases"}
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
archivesBaseName = rootProject.archives_base_name + "-neoforge"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-neoforge:${rootProject.architectury_version}"
|
||||
modImplementation "maven.modrinth:midnightlib:1.5.2-neoforge"
|
||||
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "fabric.mod.json"
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = "VisualOverhaul v$project.version - NeoForge $project.minecraft_version"
|
||||
releaseType = "$project.release_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = []
|
||||
gameLoaders = ["neoforge"]
|
||||
|
||||
mainPublication remapJar
|
||||
|
||||
relations {
|
||||
depends {
|
||||
curseforge = "midnightlib"
|
||||
modrinth = "midnightlib"
|
||||
}
|
||||
includes {}
|
||||
}
|
||||
|
||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||
if (CURSEFORGE_TOKEN != null) {
|
||||
curseforge {
|
||||
token = CURSEFORGE_TOKEN
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 17", project.minecraft_version
|
||||
releaseType = "alpha"
|
||||
}
|
||||
}
|
||||
|
||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||
if (MODRINTH_TOKEN != null) {
|
||||
modrinth {
|
||||
token = MODRINTH_TOKEN
|
||||
id = rootProject.modrinth_id
|
||||
version = "$project.version-$project.name"
|
||||
gameVersions.addAll project.minecraft_version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
loom.platform=neoforge
|
||||
@@ -1,47 +1,27 @@
|
||||
package eu.midnightdust.visualoverhaul.forge;
|
||||
package eu.midnightdust.visualoverhaul.neoforge;
|
||||
|
||||
import eu.midnightdust.visualoverhaul.IconicButtons;
|
||||
import eu.midnightdust.visualoverhaul.block.model.FurnaceWoodenPlanksModel;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.BrewingStandBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.FurnaceBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.JukeboxBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.world.BiomeColors;
|
||||
import net.minecraft.resource.*;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.event.AddPackFindersEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.resource.PathPackResources;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.neoforged.neoforge.event.AddPackFindersEvent;
|
||||
import net.neoforged.neoforgespi.locating.IModFile;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.MOD_ID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class VisualOverhaulClientEvents {
|
||||
@SubscribeEvent
|
||||
public void registerClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (VOConfig.coloredItems) {
|
||||
MinecraftClient client = VisualOverhaulClientForge.client;
|
||||
if (client.world != null && client.player != null) {
|
||||
VisualOverhaulClientForge.waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
||||
VisualOverhaulClientForge.foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
||||
VisualOverhaulClientForge.grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
||||
} else {
|
||||
VisualOverhaulClientForge.waterColor = 4159204;
|
||||
VisualOverhaulClientForge.foliageColor = -8934609;
|
||||
VisualOverhaulClientForge.grassColor = -8934609;
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void registerLayerDefinition(EntityRenderersEvent.RegisterLayerDefinitions event) {
|
||||
event.registerLayerDefinition(FurnaceWoodenPlanksModel.WOODEN_PLANKS_MODEL_LAYER, FurnaceWoodenPlanksModel::getTexturedModelData);
|
||||
@@ -77,13 +57,14 @@ public class VisualOverhaulClientEvents {
|
||||
private static void registerResourcePack(AddPackFindersEvent event, Identifier id, boolean alwaysEnabled, boolean defaultEnabled) {
|
||||
event.addRepositorySource(((profileAdder) -> {
|
||||
IModFile file = ModList.get().getModFileById(id.getNamespace()).getFile();
|
||||
try (PathPackResources pack = new PathPackResources(id.toString(), true, file.findResource("resourcepacks/" +id.getPath()))) {
|
||||
ResourcePackProfile packProfile = ResourcePackProfile.create(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), alwaysEnabled, a -> pack, ResourceType.CLIENT_RESOURCES, ResourcePackProfile.InsertionPosition.TOP, ResourcePackSource.BUILTIN);
|
||||
try {
|
||||
ResourcePackProfile.PackFactory pack = new DirectoryResourcePack.DirectoryBackedFactory(file.findResource("resourcepacks/" + id.getPath()), true);
|
||||
ResourcePackProfile packProfile = ResourcePackProfile.create(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), alwaysEnabled, pack, ResourceType.CLIENT_RESOURCES, ResourcePackProfile.InsertionPosition.TOP, ResourcePackSource.BUILTIN);
|
||||
if (packProfile != null) {
|
||||
profileAdder.accept(packProfile);
|
||||
if (defaultEnabled && !alwaysEnabled) VisualOverhaulClientForge.defaultEnabledPacks.add(packProfile);
|
||||
}
|
||||
} catch (NullPointerException e) {e.printStackTrace();}
|
||||
} catch (NullPointerException e) {e.fillInStackTrace();}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,48 @@
|
||||
package eu.midnightdust.visualoverhaul.forge;
|
||||
package eu.midnightdust.visualoverhaul.neoforge;
|
||||
|
||||
import dev.architectury.event.events.client.ClientPlayerEvent;
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaulClient;
|
||||
import eu.midnightdust.visualoverhaul.block.JukeboxTop;
|
||||
import eu.midnightdust.visualoverhaul.mixin.JukeboxBlockEntityAccessor;
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.BrewingStandBlockEntity;
|
||||
import net.minecraft.block.entity.JukeboxBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.world.BiomeColors;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderLayers;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.network.NetworkConstants;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.neoforged.fml.IExtensionPoint;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.*;
|
||||
import static net.neoforged.fml.IExtensionPoint.DisplayTest.IGNORESERVERONLY;
|
||||
|
||||
//@SuppressWarnings("all")
|
||||
@SuppressWarnings("all")
|
||||
public class VisualOverhaulClientForge {
|
||||
public static List<ResourcePackProfile> defaultEnabledPacks = Lists.newArrayList();
|
||||
public static MinecraftClient client = MinecraftClient.getInstance();
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, MOD_ID);
|
||||
public static int waterColor = 4159204;
|
||||
public static int foliageColor = -8934609;
|
||||
public static int grassColor = -8934609;
|
||||
@@ -46,36 +50,40 @@ public class VisualOverhaulClientForge {
|
||||
public static void initClient() {
|
||||
VisualOverhaulClient.onInitializeClient();
|
||||
// Block only registered on client, because it's just used for the renderer //
|
||||
BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
BLOCKS.register(Objects.requireNonNull(ModLoadingContext.get().getActiveContainer().getEventBus()));
|
||||
BLOCKS.register("jukebox_top", () -> {
|
||||
VisualOverhaulClient.JukeBoxTop = new JukeboxTop();
|
||||
return VisualOverhaulClient.JukeBoxTop;
|
||||
});
|
||||
NeoForge.EVENT_BUS.addListener(VisualOverhaulClientForge::doClientTick);
|
||||
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (remote, server) -> true));
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IGNORESERVERONLY, (remote, server) -> true));
|
||||
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () ->
|
||||
new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> MidnightConfig.getScreen(parent, MOD_ID)));
|
||||
MinecraftForge.EVENT_BUS.register(new VisualOverhaulClientEvents());
|
||||
ForgeRegistries.ITEMS.forEach((item) -> {
|
||||
Registries.ITEM.forEach((item) -> {
|
||||
if(item instanceof MusicDiscItem || item.getName().getString().toLowerCase().contains("music_disc") || item.getName().getString().toLowerCase().contains("record") || item.getName().getString().toLowerCase().contains("dynamic_disc")) {
|
||||
ModelPredicateProviderRegistry.register(item, new Identifier("round"), (stack, world, entity, seed) -> stack.getCount() == 2 ? 1.0F : 0.0F);
|
||||
}
|
||||
});
|
||||
|
||||
ClientPlayerEvent.CLIENT_PLAYER_JOIN.register(player -> {
|
||||
if (player != null) {
|
||||
NetworkManager.sendToServer(HELLO_PACKET, new PacketByteBuf(Unpooled.buffer()));
|
||||
}
|
||||
});
|
||||
|
||||
NetworkManager.registerReceiver(NetworkManager.Side.S2C, UPDATE_POTION_BOTTLES,
|
||||
(attachedData, packetSender) -> {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
DefaultedList<ItemStack> inv = DefaultedList.ofSize(5, ItemStack.EMPTY);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof BrewingStandBlockEntity blockEntity) {
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
blockEntity.setStack(3, inv.get(3));
|
||||
blockEntity.setStack(4, inv.get(4));
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
blockEntity.setStack(i, inv.get(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -84,23 +92,21 @@ public class VisualOverhaulClientForge {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
ItemStack record = attachedData.readItemStack();
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof JukeboxBlockEntity blockEntity) {
|
||||
((JukeboxBlockEntityAccessor)blockEntity).getInventory().set(0, record);
|
||||
}
|
||||
jukeboxItems.put(pos, record);
|
||||
});
|
||||
});
|
||||
NetworkManager.registerReceiver(NetworkManager.Side.S2C, UPDATE_FURNACE_ITEMS,
|
||||
(attachedData, packetSender) -> {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
DefaultedList<ItemStack> inv = DefaultedList.ofSize(3, ItemStack.EMPTY);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof AbstractFurnaceBlockEntity blockEntity) {
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
blockEntity.setStack(i, inv.get(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -109,4 +115,18 @@ public class VisualOverhaulClientForge {
|
||||
RenderLayers.setRenderLayer(Blocks.SMOKER, RenderLayer.getCutout());
|
||||
RenderLayers.setRenderLayer(Blocks.BLAST_FURNACE, RenderLayer.getCutout());
|
||||
}
|
||||
public static void doClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (VOConfig.coloredItems && event.phase == TickEvent.Phase.START) {
|
||||
MinecraftClient client = VisualOverhaulClientForge.client;
|
||||
if (client.world != null && client.player != null) {
|
||||
VisualOverhaulClientForge.waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
||||
VisualOverhaulClientForge.foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
||||
VisualOverhaulClientForge.grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
||||
} else {
|
||||
VisualOverhaulClientForge.waterColor = 4159204;
|
||||
VisualOverhaulClientForge.foliageColor = -8934609;
|
||||
VisualOverhaulClientForge.grassColor = -8934609;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package eu.midnightdust.visualoverhaul.neoforge;
|
||||
|
||||
import dev.architectury.event.events.common.PlayerEvent;
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaul;
|
||||
import net.minecraft.block.entity.BrewingStandBlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.*;
|
||||
|
||||
@Mod(MOD_ID)
|
||||
public class VisualOverhaulForge {
|
||||
|
||||
public VisualOverhaulForge() {
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) VisualOverhaulClientForge.initClient();
|
||||
|
||||
NetworkManager.registerReceiver(NetworkManager.Side.C2S, HELLO_PACKET, (attachedData, packetSender) -> VisualOverhaul.playersWithMod.add(packetSender.getPlayer().getUuid()));
|
||||
PlayerEvent.PLAYER_QUIT.register(player -> playersWithMod.remove(player.getUuid()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaul;
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
@@ -25,8 +26,10 @@ import java.util.stream.Stream;
|
||||
@Mixin(AbstractFurnaceBlockEntity.class)
|
||||
public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerBlockEntity {
|
||||
|
||||
private static boolean invUpdate = true;
|
||||
private static int playerUpdate = -1;
|
||||
@Unique
|
||||
private static boolean visualoverhaul$invUpdate = true;
|
||||
@Unique
|
||||
private static int visualoverhaul$playerUpdate = -1;
|
||||
|
||||
|
||||
protected MixinAbstractFurnaceBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
@@ -36,7 +39,7 @@ public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerB
|
||||
@Inject(at = @At("TAIL"), method = "tick")
|
||||
private static void tick(World world, BlockPos pos, BlockState state, AbstractFurnaceBlockEntity blockEntity, CallbackInfo ci) {
|
||||
if (world.getBlockState(pos).hasBlockEntity()) {
|
||||
if (!world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
|
||||
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).threadedAnvilChunkStorage.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
@@ -44,15 +47,19 @@ public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerB
|
||||
passedData.writeItemStack(blockEntity.getStack(1));
|
||||
passedData.writeItemStack(blockEntity.getStack(2));
|
||||
|
||||
watchingPlayers.forEach(player -> NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData));
|
||||
invUpdate = false;
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData);
|
||||
}
|
||||
});
|
||||
visualoverhaul$invUpdate = false;
|
||||
}
|
||||
playerUpdate = world.getPlayers().size();
|
||||
visualoverhaul$playerUpdate = world.getPlayers().size();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "getStack")
|
||||
public void getStack(int slot, CallbackInfoReturnable<ItemStack> cir) {
|
||||
invUpdate = true;
|
||||
visualoverhaul$invUpdate = true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaul;
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
@@ -25,8 +26,10 @@ import java.util.stream.Stream;
|
||||
@Mixin(BrewingStandBlockEntity.class)
|
||||
public abstract class MixinBrewingStandBlockEntity extends LockableContainerBlockEntity {
|
||||
|
||||
private static boolean invUpdate = true;
|
||||
private static int playerUpdate = -1;
|
||||
@Unique
|
||||
private static boolean visualoverhaul$invUpdate = true;
|
||||
@Unique
|
||||
private static int visualoverhaul$playerUpdate = -1;
|
||||
|
||||
protected MixinBrewingStandBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
@@ -34,7 +37,7 @@ public abstract class MixinBrewingStandBlockEntity extends LockableContainerBloc
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "tick")
|
||||
private static void tick(World world, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity, CallbackInfo ci) {
|
||||
if (!world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
|
||||
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).threadedAnvilChunkStorage.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
@@ -44,14 +47,18 @@ public abstract class MixinBrewingStandBlockEntity extends LockableContainerBloc
|
||||
passedData.writeItemStack(blockEntity.getStack(3));
|
||||
passedData.writeItemStack(blockEntity.getStack(4));
|
||||
|
||||
watchingPlayers.forEach(player -> NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_POTION_BOTTLES, passedData));
|
||||
invUpdate = false;
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_POTION_BOTTLES, passedData);
|
||||
}
|
||||
});
|
||||
visualoverhaul$invUpdate = false;
|
||||
}
|
||||
playerUpdate = world.getPlayers().size();
|
||||
visualoverhaul$playerUpdate = world.getPlayers().size();
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "getStack")
|
||||
public void getStack(int slot, CallbackInfoReturnable<ItemStack> cir) {
|
||||
invUpdate = true;
|
||||
visualoverhaul$invUpdate = true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
@@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.forge.VisualOverhaulClientForge.grassColor;
|
||||
import static eu.midnightdust.visualoverhaul.forge.VisualOverhaulClientForge.foliageColor;
|
||||
import static eu.midnightdust.visualoverhaul.forge.VisualOverhaulClientForge.waterColor;
|
||||
import static eu.midnightdust.visualoverhaul.neoforge.VisualOverhaulClientForge.grassColor;
|
||||
import static eu.midnightdust.visualoverhaul.neoforge.VisualOverhaulClientForge.foliageColor;
|
||||
import static eu.midnightdust.visualoverhaul.neoforge.VisualOverhaulClientForge.waterColor;
|
||||
|
||||
@Mixin(ItemColors.class)
|
||||
public abstract class MixinItemColors {
|
||||
@@ -28,7 +28,7 @@ public abstract class MixinItemColors {
|
||||
itemColors.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.TROPICAL_FISH_BUCKET);
|
||||
itemColors.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.SALMON_BUCKET);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.GRASS_BLOCK);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.GRASS);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.SHORT_GRASS);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.TALL_GRASS);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.FERN);
|
||||
itemColors.register((stack, tintIndex) -> grassColor, Items.LARGE_FERN);
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaul;
|
||||
@@ -38,17 +38,21 @@ public abstract class MixinJukeboxBlock extends BlockWithEntity {
|
||||
|
||||
@Nullable
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
|
||||
return world.isClient() ? null : checkType(type, BlockEntityType.JUKEBOX, MixinJukeboxBlock::tick);
|
||||
return world.isClient() ? null : validateTicker(type, BlockEntityType.JUKEBOX, MixinJukeboxBlock::visualoverhaul$tick);
|
||||
}
|
||||
@Unique
|
||||
private static void tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
|
||||
private static void visualoverhaul$tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
|
||||
if (!world.isClient && (JukeboxPacketUpdate.invUpdate || world.getPlayers().size() == JukeboxPacketUpdate.playerUpdate)) {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).threadedAnvilChunkStorage.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
passedData.writeItemStack(blockEntity.getStack());
|
||||
|
||||
watchingPlayers.forEach(player -> NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData));
|
||||
watchingPlayers.forEach(player -> {
|
||||
if (VisualOverhaul.playersWithMod.contains(player.getUuid())) {
|
||||
NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData);
|
||||
}
|
||||
});
|
||||
JukeboxPacketUpdate.invUpdate = false;
|
||||
}
|
||||
JukeboxPacketUpdate.playerUpdate = world.getPlayers().size();
|
||||
@@ -1,7 +1,7 @@
|
||||
package eu.midnightdust.visualoverhaul.forge.mixin;
|
||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
||||
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import eu.midnightdust.visualoverhaul.forge.VisualOverhaulClientForge;
|
||||
import eu.midnightdust.visualoverhaul.neoforge.VisualOverhaulClientForge;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
@@ -19,7 +19,7 @@ import static eu.midnightdust.visualoverhaul.VisualOverhaul.MOD_ID;
|
||||
public abstract class MixinResourcePackManager {
|
||||
@Shadow private List<ResourcePackProfile> enabled;
|
||||
|
||||
@Inject(method = "Lnet/minecraft/resource/ResourcePackManager;setEnabledProfiles(Ljava/util/Collection;)V", at = @At("TAIL"))
|
||||
@Inject(method = "setEnabledProfiles(Ljava/util/Collection;)V", at = @At("TAIL"))
|
||||
private void setDefaultEnabledPacks(CallbackInfo info) {
|
||||
if (VOConfig.firstLaunch) {
|
||||
List<ResourcePackProfile> enabledPacks = Lists.newArrayList();
|
||||
@@ -1,7 +1,7 @@
|
||||
package eu.midnightdust.visualoverhaul.util.forge;
|
||||
package eu.midnightdust.visualoverhaul.util.neoforge;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.neoforgespi.language.IModInfo;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[43,)"
|
||||
loaderVersion = "[1,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "MIT License"
|
||||
|
||||
@@ -12,31 +12,35 @@ description = '''
|
||||
Adds better visuals for certain Minecraft Vanilla Blocks.
|
||||
'''
|
||||
logoFile = "icon.png"
|
||||
[[mixins]]
|
||||
config = "visualoverhaul.mixins.json"
|
||||
[[mixins]]
|
||||
config = "visualoverhaul-neoforge.mixins.json"
|
||||
|
||||
[[dependencies.visualoverhaul]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[43,)"
|
||||
modId = "neoforge"
|
||||
required = true
|
||||
versionRange = "[1,)"
|
||||
ordering = "NONE"
|
||||
side = "CLIENT"
|
||||
|
||||
[[dependencies.visualoverhaul]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
required = true
|
||||
versionRange = "[1.19.2,)"
|
||||
ordering = "NONE"
|
||||
side = "CLIENT"
|
||||
|
||||
[[dependencies.visualoverhaul]]
|
||||
modId = "midnightlib"
|
||||
mandatory = true
|
||||
required = true
|
||||
versionRange = "[1.0.0,)"
|
||||
ordering = "BEFORE"
|
||||
side = "CLIENT"
|
||||
|
||||
[[dependencies.visualoverhaul]]
|
||||
modId = "architectury"
|
||||
mandatory = true
|
||||
required = true
|
||||
versionRange = "[6.0.0,)"
|
||||
ordering = "BEFORE"
|
||||
side = "BOTH"
|
||||
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "eu.midnightdust.visualoverhaul.forge.mixin",
|
||||
"package": "eu.midnightdust.visualoverhaul.neoforge.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"minVersion": "0.8",
|
||||
"mixins": [
|
||||
@@ -2,14 +2,14 @@ pluginManagement {
|
||||
repositories {
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://maven.minecraftforge.net/" }
|
||||
maven { url "https://maven.neoforged.net/releases" }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("quilt")
|
||||
include("forge")
|
||||
//include("quilt")
|
||||
include("neoforge")
|
||||
|
||||
rootProject.name = "visualoverhaul"
|
||||
|
||||
Reference in New Issue
Block a user