mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
63 lines
2.1 KiB
Java
63 lines
2.1 KiB
Java
package com.hbm.blocks.machine;
|
|
|
|
import com.hbm.inventory.container.ContainerWeaponTable;
|
|
import com.hbm.inventory.gui.GUIWeaponTable;
|
|
import com.hbm.lib.RefStrings;
|
|
import com.hbm.main.MainRegistry;
|
|
import com.hbm.tileentity.IGUIProvider;
|
|
|
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.inventory.Container;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockWeaponTable extends Block implements IGUIProvider {
|
|
|
|
@SideOnly(Side.CLIENT) private IIcon iconTop;
|
|
@SideOnly(Side.CLIENT) private IIcon iconBottom;
|
|
|
|
public BlockWeaponTable() {
|
|
super(Material.iron);
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
|
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":gun_table_top");
|
|
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":gun_table_bottom");
|
|
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":gun_table_side");
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(int side, int metadata) {
|
|
return side == 0 ? this.iconBottom : (side == 1 ? this.iconTop : this.blockIcon);
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
|
|
|
if(world.isRemote) {
|
|
return true;
|
|
} else if(!player.isSneaking()) {
|
|
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerWeaponTable(player.inventory); }
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIWeaponTable(player.inventory); }
|
|
}
|