/******************************************************************************* * Copyright (c) 2011-2014 SirSengir. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt * * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ package forestry.apiculture.multiblock; import java.io.IOException; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.Vec3; import net.minecraft.world.biome.BiomeGenBase; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; import forestry.api.apiculture.IBeekeepingLogic; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IErrorLogic; import forestry.api.multiblock.IAlvearyComponent; import forestry.api.multiblock.IMultiblockController; import forestry.apiculture.blocks.BlockAlveary; import forestry.apiculture.gui.ContainerAlveary; import forestry.apiculture.gui.GuiAlveary; import forestry.core.access.EnumAccess; import forestry.core.access.IAccessHandler; import forestry.core.access.IRestrictedAccess; import forestry.core.config.Config; import forestry.core.gui.IHintSource; import forestry.core.inventory.IInventoryAdapter; import forestry.core.multiblock.MultiblockTileEntityForestry; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamableGui; import forestry.core.tiles.IClimatised; import forestry.core.tiles.ITitled; public abstract class TileAlveary extends MultiblockTileEntityForestry implements IBeeHousing, IAlvearyComponent, IRestrictedAccess, IStreamableGui, ITitled, IClimatised, IHintSource { private final String unlocalizedTitle; protected TileAlveary() { this(BlockAlveary.Type.PLAIN); } protected TileAlveary(BlockAlveary.Type type) { super(new MultiblockLogicAlveary()); this.unlocalizedTitle = "tile.for.alveary." + type.ordinal() + ".name"; } /* TEXTURES */ public int getIcon(int side) { return BlockAlveary.PLAIN; } @Override public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) { // Re-render this block on the client if (worldObj.isRemote) { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); markDirty(); } @Override public void onMachineBroken() { // Re-render this block on the client if (worldObj.isRemote) { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); markDirty(); } /* IHousing */ @Override public BiomeGenBase getBiome() { return getMultiblockLogic().getController().getBiome(); } /* IBeeHousing */ @Override public Iterable getBeeModifiers() { return getMultiblockLogic().getController().getBeeModifiers(); } @Override public Iterable getBeeListeners() { return getMultiblockLogic().getController().getBeeListeners(); } @Override public IBeeHousingInventory getBeeInventory() { return getMultiblockLogic().getController().getBeeInventory(); } @Override public IBeekeepingLogic getBeekeepingLogic() { return getMultiblockLogic().getController().getBeekeepingLogic(); } @Override public Vec3 getBeeFXCoordinates() { return getMultiblockLogic().getController().getBeeFXCoordinates(); } /* IClimatised */ @Override public EnumTemperature getTemperature() { return getMultiblockLogic().getController().getTemperature(); } @Override public EnumHumidity getHumidity() { return getMultiblockLogic().getController().getHumidity(); } @Override public int getBlockLightValue() { return getMultiblockLogic().getController().getBlockLightValue(); } @Override public boolean canBlockSeeTheSky() { return getMultiblockLogic().getController().canBlockSeeTheSky(); } @Override public IErrorLogic getErrorLogic() { return getMultiblockLogic().getController().getErrorLogic(); } @Override public IAccessHandler getAccessHandler() { return getMultiblockLogic().getController().getAccessHandler(); } @Override public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) { getMultiblockLogic().getController().onSwitchAccess(oldAccess, newAccess); } @Override public IInventoryAdapter getInternalInventory() { return getMultiblockLogic().getController().getInternalInventory(); } @Override public String getUnlocalizedTitle() { return unlocalizedTitle; } /* IHintSource */ @Override public List getHints() { return Config.hints.get("apiary"); } /* IClimatised */ @Override public float getExactTemperature() { return getMultiblockLogic().getController().getExactTemperature(); } @Override public float getExactHumidity() { return getMultiblockLogic().getController().getExactHumidity(); } /* IStreamableGui */ @Override public void writeGuiData(DataOutputStreamForestry data) throws IOException { getMultiblockLogic().getController().writeGuiData(data); } @Override public void readGuiData(DataInputStreamForestry data) throws IOException { getMultiblockLogic().getController().readGuiData(data); } @Override public Object getGui(EntityPlayer player, int data) { return new GuiAlveary(player.inventory, this); } @Override public Object getContainer(EntityPlayer player, int data) { return new ContainerAlveary(player.inventory, this); } }