TechReborn/src/main/java/techreborn/blocks/machine/BlockIndustrialElectrolyzer.java

86 lines
2.9 KiB
Java
Raw Normal View History

2015-05-08 01:39:17 +02:00
package techreborn.blocks.machine;
2015-05-03 23:58:11 +02:00
2015-11-23 15:40:30 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2015-05-03 23:58:11 +02:00
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
2015-06-07 20:39:21 +02:00
import net.minecraft.world.IBlockAccess;
2015-05-03 23:58:11 +02:00
import net.minecraft.world.World;
import techreborn.Core;
2015-05-08 01:39:17 +02:00
import techreborn.blocks.BlockMachineBase;
2015-05-03 23:58:11 +02:00
import techreborn.client.GuiHandler;
import techreborn.tiles.TileIndustrialElectrolyzer;
2015-07-02 20:51:24 +02:00
2015-05-03 23:58:11 +02:00
public class BlockIndustrialElectrolyzer extends BlockMachineBase {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconFrontOn;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockIndustrialElectrolyzer(Material material) {
super(material);
setBlockName("techreborn.industrialelectrolyzer");
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileIndustrialElectrolyzer();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.industrialElectrolyzerID, world, x, y,
z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/industrial_electrolyzer_front_off");
this.iconFront = icon.registerIcon("techreborn:machine/industrial_electrolyzer_front_off");
this.iconFrontOn = icon.registerIcon("techreborn:machine/industrial_electrolyzer_front_on");
this.iconTop = icon.registerIcon("techreborn:machine/machine_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom");
}
@Override
2015-09-05 10:17:58 +02:00
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
2015-09-19 10:31:24 +02:00
int metadata = getTileRotation(blockAccess, x, y, z);
2015-09-05 10:17:58 +02:00
if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) {
return this.iconFrontOn;
}
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop :
side == 0 ? this.iconBottom : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
2015-09-14 22:23:07 +02:00
@Override
public IIcon getIcon(int side, int meta) {
2015-11-08 13:15:45 +01:00
if (side == 1) {
2015-09-14 22:23:07 +02:00
return this.iconTop;
2015-11-08 13:15:45 +01:00
} else if (side == 3) {
2015-09-14 22:23:07 +02:00
return this.iconFront;
} else {
return this.blockIcon;
}
}
2015-05-03 23:58:11 +02:00
}