mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-11 15:57:39 +00:00
32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
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 {
|
|
|
|
private AlignmentUtility() {}
|
|
|
|
public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) {
|
|
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
|
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
|
|
return aPlayer instanceof EntityPlayerMP;
|
|
}
|
|
if (aPlayer instanceof EntityPlayerMP && tTileEntity instanceof IAlignmentProvider) {
|
|
IAlignment alignment = ((IAlignmentProvider) tTileEntity).getAlignment();
|
|
if (alignment != null) {
|
|
if (aPlayer.isSneaking()) {
|
|
alignment.toolSetFlip(null);
|
|
} else {
|
|
alignment.toolSetRotation(null);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|