2021-05-17 03:02:24 +08:00
|
|
|
package com.gtnewhorizon.structurelib.alignment;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.common.util.FakePlayer;
|
|
|
|
|
|
|
|
|
|
public class AlignmentUtility {
|
2023-01-30 12:52:27 +00:00
|
|
|
|
2022-08-08 17:40:12 +08:00
|
|
|
private AlignmentUtility() {}
|
2021-05-17 03:02:24 +08:00
|
|
|
|
2022-07-08 17:14:18 +08:00
|
|
|
public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) {
|
2021-05-17 03:02:24 +08:00
|
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
2021-05-29 14:27:54 +08:00
|
|
|
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
|
2021-05-17 03:02:24 +08:00
|
|
|
return aPlayer instanceof EntityPlayerMP;
|
|
|
|
|
}
|
2021-05-29 14:27:54 +08:00
|
|
|
if (aPlayer instanceof EntityPlayerMP && tTileEntity instanceof IAlignmentProvider) {
|
|
|
|
|
IAlignment alignment = ((IAlignmentProvider) tTileEntity).getAlignment();
|
|
|
|
|
if (alignment != null) {
|
|
|
|
|
if (aPlayer.isSneaking()) {
|
2021-05-17 03:02:24 +08:00
|
|
|
alignment.toolSetFlip(null);
|
2021-05-29 14:27:54 +08:00
|
|
|
} else {
|
2021-05-17 03:02:24 +08:00
|
|
|
alignment.toolSetRotation(null);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|