mirror of
https://github.com/TibiNonEst/cauldron-dyeing.git
synced 2025-05-14 11:14:09 -05:00
Backport to 1.17
This commit is contained in:
parent
6418399d20
commit
3c1503af6b
9 changed files with 35 additions and 38 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"package": "me.tibinonest.mods.cauldron_dyeing.mixin.sodium",
|
||||
"required": false,
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"client": [
|
||||
"SodiumBlockRendererMixin"
|
||||
],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"package": "me.tibinonest.mods.cauldron_dyeing.mixin",
|
||||
"required": true,
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
"BlocksMixin",
|
||||
"CauldronBehaviorMixin",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue