Created
June 20, 2020 19:55
-
-
Save Andrews54757/d6b43eeab00f2447fcbe50285d80d1a9 to your computer and use it in GitHub Desktop.
Litematica Mirror Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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