Skip to content

Commit

Permalink
replaced override in block tinting mixin (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 authored Sep 18, 2023
1 parent 5bba21c commit 58550de
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package org.valkyrienskies.mod.mixin.feature.block_tint;

import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
import net.minecraft.client.color.block.BlockTintCache;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ColorResolver;
import org.joml.Vector3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.common.config.VSGameConfig;

Expand Down Expand Up @@ -44,24 +42,22 @@ private BlockPos fixBlockPos(final BlockPos old) {
);
}

@Accessor(
"tintCaches"
@Inject(
method = "getBlockTint(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/ColorResolver;)I",
at = @At("HEAD"),
cancellable = true
)
public abstract Object2ObjectArrayMap<ColorResolver, BlockTintCache> getTintCaches();

/**
* @author SuperCraftAlex
* @reason Fix block tinting for ships
*/
@Overwrite
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
public void getBlockTint(
final BlockPos blockPos,
final ColorResolver colorResolver,
final CallbackInfoReturnable<Integer> cir
) {
if (VSGameConfig.CLIENT.getBlockTinting().getFixBlockTinting() &&
VSGameUtilsKt.isBlockInShipyard(ClientLevel.class.cast(this), blockPos)
) {
return ClientLevel.class.cast(this).calculateBlockTint(blockPos, colorResolver);
cir.setReturnValue(ClientLevel.class.cast(this)
.calculateBlockTint(blockPos, colorResolver));
}
final BlockTintCache blockTintCache = getTintCaches().get(colorResolver);
return blockTintCache.getColor(blockPos);
}


Expand Down

0 comments on commit 58550de

Please sign in to comment.