mffs/src/main/java/mffs/block/BlockMachineBlock.java

69 lines
1.9 KiB
Java
Raw Normal View History

2022-10-28 16:20:12 +02:00
package mffs.block;
import mffs.base.BlockMachine;
import mffs.base.TileEntityBase;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public abstract class BlockMachineBlock extends BlockMachine {
protected IIcon blockIconTop;
protected IIcon blockIconOn;
protected IIcon blockIconTopOn;
public BlockMachineBlock(final String name) {
super(name);
}
@Override
2023-01-08 16:58:21 +01:00
public IIcon getIcon(
final IBlockAccess par1IBlockAccess,
final int x,
final int y,
final int z,
final int side
) {
2022-10-28 16:20:12 +02:00
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
2023-01-08 16:58:21 +01:00
if (tileEntity instanceof TileEntityBase
&& ((TileEntityBase) tileEntity).isActive()) {
2022-10-28 16:20:12 +02:00
if (side == 0 || side == 1) {
return this.blockIconTopOn;
}
return this.blockIconOn;
} else {
if (side == 0 || side == 1) {
return this.blockIconTop;
}
return this.blockIcon;
}
}
@Override
public void registerBlockIcons(final IIconRegister reg) {
2023-01-08 16:58:21 +01:00
this.blockIcon = reg.registerIcon(this.getUnlocalizedName().replace("tile.", ""));
this.blockIconTop
= reg.registerIcon(this.getUnlocalizedName().replace("tile.", "") + "_top");
this.blockIconOn
= reg.registerIcon(this.getUnlocalizedName().replace("tile.", "") + "_on");
2022-10-28 16:20:12 +02:00
this.blockIconTopOn = reg.registerIcon(
2023-01-08 16:58:21 +01:00
this.getUnlocalizedName().replace("tile.", "") + "_top_on"
);
2022-10-28 16:20:12 +02:00
}
@Override
public boolean isOpaqueCube() {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public int getRenderType() {
return 0;
}
}