2015-05-08 01:39:17 +02:00
|
|
|
package techreborn.blocks.machine;
|
2015-04-14 01:12:24 +02:00
|
|
|
|
2015-07-02 20:51:24 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-06-06 21:55:02 +02:00
|
|
|
import ic2.api.item.IC2Items;
|
2015-04-14 01:12:24 +02:00
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-06-06 21:55:02 +02:00
|
|
|
import net.minecraft.item.Item;
|
2015-04-14 01:12:24 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.IIcon;
|
2015-09-05 10:17:58 +02:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2015-04-14 01:12:24 +02:00
|
|
|
import net.minecraft.world.World;
|
2015-04-15 17:23:12 +02:00
|
|
|
import techreborn.Core;
|
2015-05-08 01:39:17 +02:00
|
|
|
import techreborn.blocks.BlockMachineBase;
|
2015-04-15 17:23:12 +02:00
|
|
|
import techreborn.client.GuiHandler;
|
|
|
|
import techreborn.tiles.TileRollingMachine;
|
2015-07-02 20:51:24 +02:00
|
|
|
|
|
|
|
import java.util.Random;
|
2015-04-15 17:23:12 +02:00
|
|
|
|
2015-04-28 17:18:32 +02:00
|
|
|
public class BlockRollingMachine extends BlockMachineBase {
|
2015-04-14 01:12:24 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private IIcon iconFront;
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private IIcon iconTop;
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private IIcon iconBottom;
|
2015-04-14 01:12:24 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
public BlockRollingMachine(Material material) {
|
|
|
|
super(material.rock);
|
|
|
|
setBlockName("techreborn.rollingmachine");
|
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
|
|
|
return new TileRollingMachine();
|
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@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.rollingMachineID, world,
|
|
|
|
x, y, z);
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister icon) {
|
|
|
|
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
|
|
|
|
this.iconFront = icon.registerIcon("techreborn:machine/rolling_machine_side_off");
|
|
|
|
this.iconTop = icon.registerIcon("techreborn:machine/machine_top");
|
|
|
|
this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom");
|
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-09-05 10:17:58 +02:00
|
|
|
@Override
|
2015-08-09 12:05:32 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-09-05 10:17:58 +02:00
|
|
|
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
|
|
|
int metadata = getTileMeta(blockAccess, x, y, z);
|
2015-08-09 12:05:32 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Item getItemDropped(int meta, Random random, int fortune) {
|
|
|
|
return IC2Items.getItem("machine").getItem();
|
|
|
|
}
|
2015-04-24 15:20:09 +02:00
|
|
|
|
2015-09-14 22:23:07 +02:00
|
|
|
@Override
|
|
|
|
public IIcon getIcon(int side, int meta) {
|
|
|
|
if(side == 1){
|
|
|
|
return this.iconTop;
|
|
|
|
} else if(side == 3){
|
|
|
|
return this.iconFront;
|
|
|
|
} else {
|
|
|
|
return this.blockIcon;
|
|
|
|
}
|
|
|
|
}
|
2015-04-14 01:12:24 +02:00
|
|
|
}
|