assemblyline/src/main/java/assemblyline/common/machine/crane/BlockCraneController.java

73 lines
2.1 KiB
Java
Raw Normal View History

2022-10-26 19:42:44 +02:00
package assemblyline.common.machine.crane;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
2023-02-10 17:51:10 +01:00
public class BlockCraneController extends BlockALMachine {
2022-10-26 19:42:44 +02:00
public BlockCraneController() {
super(UniversalElectricity.machine);
this.setBlockName("craneController");
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
2023-02-10 17:51:10 +01:00
public void onBlockPlacedBy(
World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack
) {
int rot = (int) Math.min((entity.rotationYaw + 315.0f) % 360.0f / 90.0f, 3.0f);
2022-10-26 19:42:44 +02:00
switch (rot) {
case 0: {
2023-02-10 17:51:10 +01:00
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.WEST.ordinal(), 3
);
2022-10-26 19:42:44 +02:00
break;
}
case 1: {
2023-02-10 17:51:10 +01:00
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.NORTH.ordinal(), 3
);
2022-10-26 19:42:44 +02:00
break;
}
case 2: {
2023-02-10 17:51:10 +01:00
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.EAST.ordinal(), 3
);
2022-10-26 19:42:44 +02:00
break;
}
default: {
2023-02-10 17:51:10 +01:00
world.setBlockMetadataWithNotify(
x, y, z, ForgeDirection.SOUTH.ordinal(), 3
);
2022-10-26 19:42:44 +02:00
}
}
}
@Override
2023-02-10 17:51:10 +01:00
@SideOnly(value = Side.CLIENT)
2022-10-26 19:42:44 +02:00
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityCraneController();
}
}