package mcjty.deepresonance.blocks.smelter;
import mcjty.deepresonance.blocks.GenericDRBlock;
import mcjty.deepresonance.client.ClientHandler;
import mcjty.deepresonance.gui.GuiProxy;
import mcjty.lib.container.GenericGuiContainer;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import java.util.List;
public class SmelterBlock extends GenericDRBlock<SmelterTileEntity, SmelterContainer> {
public static final PropertyBool WORKING = PropertyBool.create("working");
public SmelterBlock() {
super(Material.ROCK, SmelterTileEntity.class, SmelterContainer.class, "smelter", true);
}
@SideOnly(Side.CLIENT)
@Override
public Class<? extends GenericGuiContainer> getGuiClass() {
return GuiSmelter.class;
}
@Override
@SideOnly(Side.CLIENT)
public List<String> getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currentTip;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean advancedToolTip) {
super.addInformation(itemStack, player, list, advancedToolTip);
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
list.add("This machine smelts resonating ore and produces liquid");
list.add("crystal in a tank placed on top of this.");
list.add("Below the smelter place a tank about half-filled with lava");
} else {
list.add(TextFormatting.WHITE + ClientHandler.getShiftMessage());
}
}
@Override
public int getGuiID() {
return GuiProxy.GUI_SMELTER;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(WORKING, (meta & 8) != 0);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(FACING).getIndex() + (state.getValue(WORKING) ? 8 : 0);
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FACING, WORKING);
}
}