Backport to 1.17

This commit is contained in:
tibs 2022-01-22 12:35:37 -05:00
parent 6418399d20
commit 3c1503af6b
Signed by untrusted user who does not match committer: tibs
GPG key ID: 047833989F50F88F
9 changed files with 35 additions and 38 deletions

View file

@ -8,11 +8,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
java-version: 16
- name: Build with Gradle
run: ./gradlew build

View file

@ -11,11 +11,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
java-version: 16
- name: Build with Gradle
run: ./gradlew build

View file

@ -4,8 +4,8 @@ plugins {
id 'org.ajoberstar.grgit' version '4.1.0'
}
sourceCompatibility = '17'
targetCompatibility = '17'
sourceCompatibility = '16'
targetCompatibility = '16'
archivesBaseName = project.archives_base_name
version = "${project.mod_version}${getVersionMetadata()}"
@ -27,7 +27,8 @@ var apiModules = [
"fabric-mining-level-api-v1",
"fabric-resource-loader-v0",
"fabric-tag-extensions-v0",
"fabric-object-builder-api-v1"
"fabric-object-builder-api-v1",
"fabric-networking-blockentity-v0"
]
dependencies {

View file

@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.18
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.65
loader_version=0.12.12
fabric_version=0.46.0+1.18
fabric_version=0.46.1+1.17
# Mod Properties
mod_version=1.0.0
@ -14,4 +14,4 @@ maven_group=me.tibinonest.mods
archives_base_name=cauldron-dying
# Dependencies
sodium_version=mc1.18.1-0.4.0-alpha6
sodium_version=mc1.17.1-0.3.4

View file

@ -2,18 +2,14 @@ package me.tibinonest.mods.cauldron_dyeing.block;
import com.google.common.primitives.Ints;
import me.tibinonest.mods.cauldron_dyeing.CauldronDyeing;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;
public class WaterCauldronBlockEntity extends BlockEntity {
public class WaterCauldronBlockEntity extends BlockEntity implements BlockEntityClientSerializable {
private int[] color;
public WaterCauldronBlockEntity(BlockPos pos, BlockState state) {
@ -65,9 +61,10 @@ public class WaterCauldronBlockEntity extends BlockEntity {
}
@Override
public void writeNbt(NbtCompound tag) {
public NbtCompound writeNbt(NbtCompound tag) {
super.writeNbt(tag);
tag.putIntArray("color", color);
return tag;
}
@Override
@ -78,16 +75,14 @@ public class WaterCauldronBlockEntity extends BlockEntity {
}
@Override
public NbtCompound toInitialChunkDataNbt() {
var nbt = new NbtCompound();
nbt.putIntArray("color", color);
return nbt;
public void fromClientTag(NbtCompound tag) {
color = tag.getIntArray("color");
}
@Nullable
@Override
public Packet<ClientPlayPacketListener> toUpdatePacket() {
return BlockEntityUpdateS2CPacket.create(this);
public NbtCompound toClientTag(NbtCompound tag) {
tag.putIntArray("color", color);
return tag;
}
@Override
@ -96,7 +91,7 @@ public class WaterCauldronBlockEntity extends BlockEntity {
if (world.isClient()) {
CauldronDyeing.rebuildBlock(pos);
} else {
((ServerWorld) world).getChunkManager().markForUpdate(pos);
sync();
}
super.markDirty();
}

View file

@ -1,9 +1,9 @@
package me.tibinonest.mods.cauldron_dyeing.mixin.sodium;
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadColorProvider;
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
import me.jellysquid.mods.sodium.client.model.quad.blender.ColorBlender;
import me.jellysquid.mods.sodium.client.model.quad.blender.ColorSampler;
import me.jellysquid.mods.sodium.client.model.quad.blender.FlatColorBlender;
import me.jellysquid.mods.sodium.client.model.quad.blender.BiomeColorBlender;
import me.jellysquid.mods.sodium.client.model.quad.blender.FlatBiomeColorBlender;
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
import me.tibinonest.mods.cauldron_dyeing.block.WaterCauldronBlockEntity;
import net.minecraft.util.math.BlockPos;
@ -14,15 +14,15 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BlockRenderer.class)
public class SodiumBlockRendererMixin {
@Redirect(method = "renderQuad", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/model/quad/blender/ColorBlender;getColors(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/util/math/BlockPos;Lme/jellysquid/mods/sodium/client/model/quad/ModelQuadView;Lme/jellysquid/mods/sodium/client/model/quad/blender/ColorSampler;Ljava/lang/Object;)[I"))
private <T> int[] redirectGetColors(ColorBlender instance, BlockRenderView world, BlockPos pos, ModelQuadView quad, ColorSampler<T> sampler, T state) {
@Redirect(method = "renderQuad", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/model/quad/blender/BiomeColorBlender;getColors(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/util/math/BlockPos;Lme/jellysquid/mods/sodium/client/model/quad/ModelQuadView;Lme/jellysquid/mods/sodium/client/model/quad/ModelQuadColorProvider;Ljava/lang/Object;)[I"))
private <T> int[] redirectGetColors(BiomeColorBlender instance, BlockRenderView world, BlockPos pos, ModelQuadView quad, ModelQuadColorProvider<T> handler, T fluidState) {
var blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof WaterCauldronBlockEntity) {
var flatBiomeColorBlender = new FlatColorBlender();
return flatBiomeColorBlender.getColors(world, pos, quad, sampler, state);
var flatBiomeColorBlender = new FlatBiomeColorBlender();
return flatBiomeColorBlender.getColors(world, pos, quad, handler, fluidState);
}
return instance.getColors(world, pos, quad, sampler, state);
return instance.getColors(world, pos, quad, handler, fluidState);
}
}

View file

@ -1,7 +1,7 @@
{
"package": "me.tibinonest.mods.cauldron_dyeing.mixin.sodium",
"required": false,
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_16",
"client": [
"SodiumBlockRendererMixin"
],

View file

@ -1,7 +1,7 @@
{
"package": "me.tibinonest.mods.cauldron_dyeing.mixin",
"required": true,
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_16",
"mixins": [
"BlocksMixin",
"CauldronBehaviorMixin",

View file

@ -24,8 +24,9 @@
"cauldron-dyeing.compat.sodium.mixins.json"
],
"depends": {
"minecraft": ">=1.18",
"minecraft": ">=1.17",
"fabricloader": ">=0.12.0",
"fabric-object-builder-api-v1": ">=0.1"
"fabric-object-builder-api-v1": ">=0.1",
"fabric-networking-blockentity-v0": ">=0.1"
}
}