Files
StructureLib/src/main/java/com/gtnewhorizon/structurelib/alignment/AlignmentUtility.java
T

31 lines
1.1 KiB
Java
Raw Normal View History

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);
2021-05-29 14:27:54 +08:00
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
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()) {
alignment.toolSetFlip(null);
2021-05-29 14:27:54 +08:00
} else {
alignment.toolSetRotation(null);
}
return true;
}
}
return false;
}
}