Search in sources :

Example 1 with WindowGuiCrafting

use of com.minecolonies.coremod.client.gui.WindowGuiCrafting in project minecolonies by Minecolonies.

the class GuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z) {
    if (id == ID.DEFAULT.ordinal()) {
        final BlockPos pos = new BlockPos(x, y, z);
        final TileEntity tileEntity = world.getTileEntity(pos);
        if (tileEntity instanceof ScarecrowTileEntity) {
            return new GuiField(player.inventory, (ScarecrowTileEntity) tileEntity, world, pos);
        } else if (tileEntity instanceof TileEntityRack) {
            return new GuiRack(player.inventory, (TileEntityRack) tileEntity, ((TileEntityRack) tileEntity).getOtherChest(), world, pos);
        } else {
            @Nullable final AbstractBuildingView building = ColonyManager.getBuildingView(new BlockPos(x, y, z));
            if (building instanceof AbstractBuildingWorker.View) {
                return new WindowGuiCrafting(player.inventory, world, (AbstractBuildingWorker.View) building);
            }
        }
    } else if (id == ID.BUILDING_INVENTORY.ordinal()) {
        final TileEntity entity = world.getTileEntity(new BlockPos(x, y, z));
        if (entity instanceof TileEntityColonyBuilding) {
            final TileEntityColonyBuilding tileEntityColonyBuilding = (TileEntityColonyBuilding) entity;
            return new GuiChest(player.inventory, tileEntityColonyBuilding);
        }
    } else if (id == ID.CITIZEN_INVENTORY.ordinal()) {
        final ColonyView view = ColonyManager.getColonyView(x);
        final CitizenDataView citizenDataView = view.getCitizen(y);
        return new GuiChest(player.inventory, citizenDataView.getInventory());
    }
    return null;
}
Also used : TileEntityColonyBuilding(com.minecolonies.coremod.tileentities.TileEntityColonyBuilding) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) TileEntity(net.minecraft.tileentity.TileEntity) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) TileEntityRack(com.minecolonies.coremod.tileentities.TileEntityRack) AbstractBuildingWorker(com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker) WindowGuiCrafting(com.minecolonies.coremod.client.gui.WindowGuiCrafting) BlockPos(net.minecraft.util.math.BlockPos) GuiChest(net.minecraft.client.gui.inventory.GuiChest)

Aggregations

WindowGuiCrafting (com.minecolonies.coremod.client.gui.WindowGuiCrafting)1 AbstractBuildingWorker (com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker)1 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)1 ScarecrowTileEntity (com.minecolonies.coremod.tileentities.ScarecrowTileEntity)1 TileEntityColonyBuilding (com.minecolonies.coremod.tileentities.TileEntityColonyBuilding)1 TileEntityRack (com.minecolonies.coremod.tileentities.TileEntityRack)1 GuiChest (net.minecraft.client.gui.inventory.GuiChest)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1