Skip to content

Instantly share code, notes, and snippets.

@Andrews54757
Created June 20, 2020 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrews54757/d6b43eeab00f2447fcbe50285d80d1a9 to your computer and use it in GitHub Desktop.
Save Andrews54757/d6b43eeab00f2447fcbe50285d80d1a9 to your computer and use it in GitHub Desktop.
Litematica Mirror Fix
package fi.dy.masa.litematica.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockState;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.enums.ChestType;
import net.minecraft.util.BlockMirror;
@Mixin({ChestBlock.class})
public class MixinChestBlock
{
@Inject(method = "mirror", at = @At("HEAD"), cancellable = true)
public void mirrorFixed(BlockState state, BlockMirror mirror, CallbackInfoReturnable<BlockState> c)
{
ChestType type = state.get(ChestBlock.CHEST_TYPE);
if (type != ChestType.SINGLE)
{
// Flip chest type. (Note: It would be nice to use chestType.getOpposite)
state = state.with(ChestBlock.CHEST_TYPE, type == ChestType.LEFT ? ChestType.RIGHT : ChestType.LEFT);
// Apply rotation
state = state.rotate(mirror.getRotation(state.get(ChestBlock.FACING)));
c.setReturnValue(state);
c.cancel();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment