diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/xmod/forestry | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/forestry')
15 files changed, 1521 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java new file mode 100644 index 0000000000..ff26064e98 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -0,0 +1,34 @@ +package gtPlusPlus.xmod.forestry; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry; +import gtPlusPlus.xmod.forestry.bees.recipe.FR_Gregtech_Recipes; +import cpw.mods.fml.common.registry.GameRegistry; + +public class HANDLER_FR { + + public static void preInit(){ + if (LoadedMods.Forestry){ + FR_ItemRegistry.Register(); + if (CORE.configSwitches.enableCustomAlvearyBlocks){ + GameRegistry.registerTileEntity(TileAlvearyFrameHousing.class, "FrameHousing"); + } + //FR_BlockRegistryApiculture.RegistryApiculture(); + } + } + + public static void Init(){ + if (LoadedMods.Forestry){ + //FR_TileHandler.init(); + //new FR_GuiIDRegistry(); + } + } + + public static void postInit(){ + if (LoadedMods.Forestry){ + FR_Gregtech_Recipes.registerItems(); + } + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_AlvearyFrameBlock.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_AlvearyFrameBlock.java new file mode 100644 index 0000000000..2f4437afd1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_AlvearyFrameBlock.java @@ -0,0 +1,45 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import net.minecraft.util.ChunkCoordinates; + +import com.mojang.authlib.GameProfile; + +import forestry.api.multiblock.IAlvearyComponent; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockController; +import forestry.api.multiblock.IMultiblockLogicAlveary; + +public class FR_AlvearyFrameBlock implements IAlvearyComponent, IMultiblockComponent{ + + @Override + public ChunkCoordinates getCoordinates() { + // TODO Auto-generated method stub + return null; + } + + @Override + public GameProfile getOwner() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void onMachineAssembled(IMultiblockController arg0, + ChunkCoordinates arg1, ChunkCoordinates arg2) { + // TODO Auto-generated method stub + + } + + @Override + public void onMachineBroken() { + // TODO Auto-generated method stub + + } + + @Override + public IMultiblockLogicAlveary getMultiblockLogic() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_BlockAlveary.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_BlockAlveary.java new file mode 100644 index 0000000000..f087ad75f4 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_BlockAlveary.java @@ -0,0 +1,274 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.apiculture.MaterialBeehive; +import forestry.apiculture.multiblock.TileAlvearyPlain; +import forestry.core.blocks.BlockStructure; +import forestry.core.render.TextureManager; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class FR_BlockAlveary extends BlockStructure +{ + + public static enum Type + { + PLAIN, + ERROR, + FRAME, + MUTATOR, + + //Placeholder Values + HEATER, HYGRO, STABILIZER, SIEVE; + + public static final Type[] VALUES = values(); + + private Type() {} + } + + public FR_BlockAlveary() + { + super(new MaterialBeehive(false)); + setHardness(1.0F); + setCreativeTab(AddToCreativeTab.tabBlock); + setHarvestLevel("axe", 0); + + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) + { + if (world.isRemote) return true; + + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileAlvearyFrameHousing) + { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + /*else if (te != null && te instanceof TileAlvearyFrameHousing) + { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + }*/ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List list) + { + for (int i = 0; i < 4; i++) { + if (i != 1 && i != 0) { + list.add(new ItemStack(item, 1, i)); + } + } + } + + @Override + public int getRenderType() + { + return 0; + } + + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList<ItemStack> drop = new ArrayList<ItemStack>(); + drop.add(new ItemStack(this, 1, metadata != 1 ? metadata : 0)); + return drop; + } + + @Override + public int getDamageValue(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + return meta != 1 ? meta : 0; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) + { + if ((metadata < 0) || (metadata > Type.VALUES.length)) { + return null; + } + + + + Type type = Type.VALUES[metadata]; + switch (type) + { + case FRAME: + LanguageRegistry.addName(this, "Alveary Frame Housing"); + case MUTATOR: + LanguageRegistry.addName(this, "Alveary Mutator Block"); + case ERROR: + LanguageRegistry.addName(this, "Invalid Alveary Block"); + default: + LanguageRegistry.addName(this, "Unnamed Alveary Block"); + } + switch (type) + { + case FRAME: + return new TileAlvearyFrameHousing(); + case MUTATOR: + return new TileAlvearyPlain(); + case ERROR: + return new TileAlvearyPlain(); + default: + return new TileAlvearyPlain(); + } + } + + @Override + public Block setBlockName(String name) { + //int meta = this. + return super.setBlockName(name); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return createTileEntity(world, meta); + } + + /* ICONS */ + public static final int PLAIN = 0; + public static final int ENTRANCE = 1; + public static final int BOTTOM = 2; + public static final int LEFT = 3; + public static final int RIGHT = 4; + public static final int ALVEARY_FRAME_OFF = 5; + public static final int ALVEARY_FRAME_ON = 6; + public static final int ALVEARY_MUTATOR_OFF = 7; + public static final int ALVEARY_MUTATOR_ON = 8; + @SideOnly(Side.CLIENT) + private IIcon[] icons; + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister register) { + icons = new IIcon[9]; + icons[0] = TextureManager.registerTex(register, "apiculture/alveary.plain"); + icons[1] = TextureManager.registerTex(register, "apiculture/alveary.entrance"); + icons[2] = TextureManager.registerTex(register, "apiculture/alveary.bottom"); + icons[3] = TextureManager.registerTex(register, "apiculture/alveary.left"); + icons[4] = TextureManager.registerTex(register, "apiculture/alveary.right"); + icons[5] = TextureManager.registerTex(register, "apiculture/alveary.framehousing.off"); + icons[6] = TextureManager.registerTex(register, "apiculture/alveary.framehousing.on"); + icons[7] = TextureManager.registerTex(register, "apiculture/alveary.mutator.off"); + icons[8] = TextureManager.registerTex(register, "apiculture/alveary.mutator.on"); + } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int metadata) { + if ((metadata <= 1 + || metadata == Type.FRAME.ordinal() || metadata == Type.MUTATOR.ordinal()) + && (side == 1 || side == 0)) { + return icons[BOTTOM]; + } + Type type = Type.VALUES[metadata]; + switch (type) { + case ERROR: + return icons[PLAIN]; + case FRAME: + return icons[ALVEARY_FRAME_OFF]; + case MUTATOR: + return icons[ALVEARY_MUTATOR_OFF]; + case HEATER: + return icons[ALVEARY_MUTATOR_OFF]; + case HYGRO: + return icons[ALVEARY_MUTATOR_OFF]; + case STABILIZER: + return icons[PLAIN]; + case SIEVE: + return icons[PLAIN]; + default: + return null; + } + } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 1) { + return this.getIcon(side, meta); + } else if (meta > 1) { + return getBlockTextureFromSideAndTile(world, x, y, z, side); + } + Block blockXP = world.getBlock(x + 1, y, z); + Block blockXM = world.getBlock(x - 1, y, z); + if (blockXP == this && blockXM != this) { + if (world.getBlockMetadata(x + 1, y, z) == 1) { + if (world.getBlock(x, y, z + 1) != this) { + return switchForSide(42, side); + } + return switchForSide(41, side); + } + return this.getIcon(side, meta); + } else if (blockXP != this && blockXM == this) { + if (world.getBlockMetadata(x - 1, y, z) == 1) { + if (world.getBlock(x, y, z + 1) != this) { + return switchForSide(41, side); + } + return switchForSide(42, side); + } + return this.getIcon(side, meta); + } + return this.getIcon(side, meta); + } + @SideOnly(Side.CLIENT) + private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof FR_TileAlveary)) { + return getIcon(side, 0); + } + return icons[((FR_TileAlveary) tile).getIcon(side)]; + } + @SideOnly(Side.CLIENT) + private IIcon switchForSide(int textureId, int side) { + if (side == 4 || side == 5) { + if (textureId == 41) { + return icons[LEFT]; + } + return icons[RIGHT]; + } else if (textureId == 41) { + return icons[RIGHT]; + } else { + return icons[LEFT]; + } + } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof FR_TileAlveary) { + FR_TileAlveary tileAlveary = (FR_TileAlveary) tileEntity; + // We must check that the slabs on top were not removed + tileAlveary.getMultiblockLogic().getController().reassemble(); + } + } + public ItemStack get(Type type) { + return new ItemStack(this, 1, type.ordinal()); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_TileAlveary.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_TileAlveary.java new file mode 100644 index 0000000000..b5b3b73e6b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/FR_TileAlveary.java @@ -0,0 +1,199 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import java.io.IOException; +import java.util.List; + +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.multiblock.MultiblockLogicAlveary; +import forestry.core.access.EnumAccess; +import forestry.core.access.IAccessHandler; +import forestry.core.access.IRestrictedAccess; +import forestry.core.config.Config; +import forestry.core.gui.IGuiHandlerForestry; +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 FR_TileAlveary +extends MultiblockTileEntityForestry<MultiblockLogicAlveary> +implements IBeeHousing, IAlvearyComponent, IRestrictedAccess, IStreamableGui, ITitled, IClimatised, IHintSource, IGuiHandlerForestry +{ + private final String unlocalizedTitle; + + protected FR_TileAlveary() + { + this(FR_BlockAlveary.Type.ERROR); + } + + protected FR_TileAlveary(FR_BlockAlveary.Type type) + { + super(new MultiblockLogicAlveary()); + this.unlocalizedTitle = ("advanced.tile.for.alveary." + type.ordinal() + ".name"); + + } + + public int getIcon(int side) + { + return 0; + } + + @Override + public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) + { + if (this.worldObj.isRemote) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, getBlockType()); + markDirty(); + } + + @Override + public void onMachineBroken() + { + if (this.worldObj.isRemote) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, getBlockType()); + markDirty(); + } + + @Override + public BiomeGenBase getBiome() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBiome(); + } + + @Override + public Iterable<IBeeModifier> getBeeModifiers() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeModifiers(); + } + + @Override + public Iterable<IBeeListener> getBeeListeners() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeListeners(); + } + + @Override + public IBeeHousingInventory getBeeInventory() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeInventory(); + } + + @Override + public IBeekeepingLogic getBeekeepingLogic() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeekeepingLogic(); + } + + @Override + public Vec3 getBeeFXCoordinates() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeFXCoordinates(); + } + + @Override + public EnumTemperature getTemperature() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getTemperature(); + } + + @Override + public EnumHumidity getHumidity() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getHumidity(); + } + + @Override + public int getBlockLightValue() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBlockLightValue(); + } + + @Override + public boolean canBlockSeeTheSky() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().canBlockSeeTheSky(); + } + + @Override + public IErrorLogic getErrorLogic() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getErrorLogic(); + } + + @Override + public IAccessHandler getAccessHandler() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getAccessHandler(); + } + + @Override + public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) + { + ((MultiblockLogicAlveary)getMultiblockLogic()).getController().onSwitchAccess(oldAccess, newAccess); + } + + @Override + public IInventoryAdapter getInternalInventory() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getInternalInventory(); + } + + @Override + public String getUnlocalizedTitle() + { + return this.unlocalizedTitle; + } + + @Override + public List<String> getHints() + { + return Config.hints.get("apiary"); + } + + @Override + public float getExactTemperature() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getExactTemperature(); + } + + @Override + public float getExactHumidity() + { + return ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getExactHumidity(); + } + + @Override + public void writeGuiData(DataOutputStreamForestry data) + throws IOException + { + ((MultiblockLogicAlveary)getMultiblockLogic()).getController().writeGuiData(data); + } + + @Override + public void readGuiData(DataInputStreamForestry data) + throws IOException + { + ((MultiblockLogicAlveary)getMultiblockLogic()).getController().readGuiData(data); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/IAlvearyComponentAdvanced.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/IAlvearyComponentAdvanced.java new file mode 100644 index 0000000000..b55d2d37a6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/IAlvearyComponentAdvanced.java @@ -0,0 +1,28 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import forestry.api.apiculture.IBeeModifier; +import forestry.api.core.IClimateControlled; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockLogicAlveary; + +public abstract interface IAlvearyComponentAdvanced<T extends IMultiblockLogicAlveary> +extends IMultiblockComponent +{ + @Override + public abstract T getMultiblockLogic(); + + + public static abstract interface FrameHouse + extends IAlvearyComponentAdvanced + { + public abstract void changeClimate(int paramInt, IClimateControlled paramIClimateControlled); + } + + + public static abstract interface BeeModifier + extends IAlvearyComponentAdvanced + { + public abstract IBeeModifier getBeeModifier(); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/ISidedFrameWearingInventory.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/ISidedFrameWearingInventory.java new file mode 100644 index 0000000000..523c3e2434 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/ISidedFrameWearingInventory.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import net.minecraft.inventory.ISidedInventory; +import forestry.api.apiculture.IBeeHousing; + +public abstract interface ISidedFrameWearingInventory + extends ISidedInventory +{ + public abstract void wearOutFrames(IBeeHousing paramIBeeHousing, int paramInt); +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/TileAlvearyFrameHousing.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/TileAlvearyFrameHousing.java new file mode 100644 index 0000000000..12f97b5f0c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/TileAlvearyFrameHousing.java @@ -0,0 +1,301 @@ +package gtPlusPlus.xmod.forestry.bees.alveary; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import forestry.api.apiculture.BeeManager; +import forestry.api.apiculture.IBee; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IBeeModifier; +import forestry.api.apiculture.IBeekeepingMode; +import forestry.api.apiculture.IHiveFrame; +import forestry.api.multiblock.IAlvearyComponent; +import forestry.apiculture.ApiaryBeeModifier; +import forestry.apiculture.multiblock.MultiblockLogicAlveary; +import forestry.apiculture.network.packets.PacketActiveUpdate; +import forestry.apiculture.worldgen.Hive; +import forestry.apiculture.worldgen.HiveDecorator; +import forestry.apiculture.worldgen.HiveDescriptionSwarmer; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.wrappers.IInvSlot; +import forestry.core.inventory.wrappers.InventoryIterator; +import forestry.core.proxy.Proxies; +import forestry.core.tiles.IActivatable; +import forestry.core.utils.ItemStackUtil; +import gtPlusPlus.xmod.forestry.bees.alveary.gui.CONTAINER_FrameHousing; +import gtPlusPlus.xmod.forestry.bees.alveary.gui.GUI_FrameHousing; +import gtPlusPlus.xmod.forestry.bees.alveary.gui.InventoryFrameHousing; + +public class TileAlvearyFrameHousing +extends FR_TileAlveary +implements ISidedFrameWearingInventory, IActivatable, IAlvearyComponent.Active, IAlvearyComponent.BeeModifier +{ + private final InventoryFrameHousing inventory; + private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>(); + private boolean active; + + public TileAlvearyFrameHousing() + { + super(FR_BlockAlveary.Type.FRAME); + this.inventory = new InventoryFrameHousing(this); + + } + + @Override + public IInventoryAdapter getInternalInventory() + { + return this.inventory; + } + + @Override + public boolean allowsAutomation() + { + return true; + } + + @Override + public void updateServer(int tickCount) + { + + if (getInternalInventory() == null) { + return; + } + + if (this.inventory.getStackInSlot(0) != null) + { + setActive(true); + if (tickCount % 1000 == 0) { + wearOutFrames(this, 1); + } + } + else + { + setActive(false); + } + if (tickCount % 500 != 0) { + return; + } + + } + + @Override + public void updateClient(int tickCount) {} + + private ItemStack getPrincessStack() + { + ItemStack princessStack = ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeInventory().getQueen(); + if (BeeManager.beeRoot.isMated(princessStack)) { + return princessStack; + } + return null; + } + + private int consumeInducerAndGetChance() + { + if (getInternalInventory() == null) { + return 0; + } + for (Iterator<?> i$ = InventoryIterator.getIterable(getInternalInventory()).iterator(); i$.hasNext();) + { + IInvSlot slot = (IInvSlot)i$.next(); + ItemStack stack = slot.getStackInSlot(); + for (Map.Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) { + if (ItemStackUtil.isIdenticalItem((ItemStack)entry.getKey(), stack)) + { + slot.decreaseStackInSlot(); + return ((Integer)entry.getValue()).intValue(); + } + } + } + IInvSlot slot; + ItemStack stack; + return 0; + } + + private void trySpawnSwarm() + { + ItemStack toSpawn = (ItemStack)this.pendingSpawns.peek(); + HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(new ItemStack[] { toSpawn }); + Hive hive = new Hive(hiveDescription); + + int chunkX = (this.xCoord + this.worldObj.rand.nextInt(80) - 40) / 16; + int chunkZ = (this.zCoord + this.worldObj.rand.nextInt(80) - 40) / 16; + if (HiveDecorator.genHive(this.worldObj, this.worldObj.rand, chunkX, chunkZ, hive)) { + this.pendingSpawns.pop(); + } + } + + @Override + protected void encodeDescriptionPacket(NBTTagCompound packetData) + { + super.encodeDescriptionPacket(packetData); + packetData.setBoolean("Active", this.active); + } + + @Override + protected void decodeDescriptionPacket(NBTTagCompound packetData) + { + super.decodeDescriptionPacket(packetData); + setActive(packetData.getBoolean("Active")); + } + + @Override + public int getIcon(int side) + { + if ((side == 0) || (side == 1)) { + return 2; + } + if (this.active) { + return 6; + } + return 5; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + setActive(nbttagcompound.getBoolean("Active")); + + NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10); + for (int i = 0; i < nbttaglist.tagCount(); i++) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + this.pendingSpawns.add(ItemStack.loadItemStackFromNBT(nbttagcompound1)); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setBoolean("Active", this.active); + + NBTTagList nbttaglist = new NBTTagList(); + ItemStack[] offspring = (ItemStack[])this.pendingSpawns.toArray(new ItemStack[this.pendingSpawns.size()]); + for (int i = 0; i < offspring.length; i++) { + if (offspring[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + offspring[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + nbttagcompound.setTag("PendingSpawns", nbttaglist); + } + + @Override + public boolean isActive() + { + return this.active; + } + + @Override + public void setActive(boolean active) + { + if (this.active == active) { + return; + } + this.active = active; + if (!this.worldObj.isRemote) { + Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), this.worldObj); + } + } + + @Override + public Object getGui(EntityPlayer player, int data) + { + return new GUI_FrameHousing(this, player); + } + + @Override + public Object getContainer(EntityPlayer player, int data) + { + return new CONTAINER_FrameHousing(this, player); + } + + private final IBeeModifier beeModifier = new ApiaryBeeModifier(); + //private final IBeeListener beeListener = new ApiaryBeeListener(this); + + @Override + public Collection<IBeeModifier> getBeeModifiers() + { + List<IBeeModifier> beeModifiers = new ArrayList<IBeeModifier>(); + + beeModifiers.add(this.beeModifier); + for (IHiveFrame frame : getFrames(this.inventory)) { + beeModifiers.add(frame.getBeeModifier()); + } + return beeModifiers; + } + + public Collection<IHiveFrame> getFrames(IInventory inventory) + { + Collection<IHiveFrame> hiveFrames = new ArrayList<IHiveFrame>(inventory.getSizeInventory()); + for (int i = 0; i < inventory.getSizeInventory(); i++) + { + ItemStack stackInSlot = getStackInSlot(i); + if (stackInSlot != null) + { + Item itemInSlot = stackInSlot.getItem(); + if ((itemInSlot instanceof IHiveFrame)) { + hiveFrames.add((IHiveFrame)itemInSlot); + } + } + } + return hiveFrames; + } + + @Override + public IBeeModifier getBeeModifier() { + List<IBeeModifier> beeModifiers = new ArrayList<IBeeModifier>(); + + beeModifiers.add(this.beeModifier); + for (IHiveFrame frame : getFrames(this.inventory)) { + beeModifiers.add(frame.getBeeModifier()); + } + return beeModifiers.get(0); + } + + private ItemStack getQueenStack() + { + ItemStack queenStack = ((MultiblockLogicAlveary)getMultiblockLogic()).getController().getBeeInventory().getQueen(); + return queenStack; + } + + @Override + public void wearOutFrames(IBeeHousing beeHousing, int amount) + { + IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorld()); + int wear = Math.round(amount * beekeepingMode.getWearModifier()); + for (int i = 0; i < this.inventory.getSizeInventory(); i++) + { + ItemStack hiveFrameStack = getStackInSlot(i); + if (hiveFrameStack != null) + { + Item hiveFrameItem = hiveFrameStack.getItem(); + if ((hiveFrameItem instanceof IHiveFrame)) + { + IHiveFrame hiveFrame = (IHiveFrame)hiveFrameItem; + + ItemStack queenStack = getQueenStack(); + IBee queen = BeeManager.beeRoot.getMember(queenStack); + ItemStack usedFrame = hiveFrame.frameUsed(beeHousing, hiveFrameStack, queen, wear); + + setInventorySlotContents(i, usedFrame); + } + } + } + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java new file mode 100644 index 0000000000..c685482266 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/CONTAINER_FrameHousing.java @@ -0,0 +1,98 @@ +package gtPlusPlus.xmod.forestry.bees.alveary.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import forestry.api.apiculture.IHiveFrame; +import forestry.core.gui.tooltips.ToolTip; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.slots.SlotFrame; +import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; + +public class CONTAINER_FrameHousing extends Container +{ + private TileAlvearyFrameHousing te; + + public static final int INPUT_1 = 0; + private final ResourceLocation beeFrameIcon = new ResourceLocation(CORE.MODID, "textures/items/machine_Charger.png"); + public ToolTip newTip = new ToolTip(); + private final SlotFrame beeFrameSlot; + + private int slotID = 0; + + public CONTAINER_FrameHousing(TileAlvearyFrameHousing te, EntityPlayer player) + { + this.te = te; + this.beeFrameSlot = new SlotFrame(te, slotID++, 80, 35); + + //Fuel Slot A + beeFrameSlot.setBackgroundIconTexture(beeFrameIcon); + + addSlotToContainer(beeFrameSlot); + + //Inventory + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 9; j++) + { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) + { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) + { + ItemStack stack = null; + Slot slot = (Slot)inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) + { + ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + + //If your inventory only stores certain instances of Items, + //you can implement shift-clicking to your inventory like this: + // Check that the item is the right type + if (!(stack.getItem() instanceof IHiveFrame)){ + return null; + } + + if (slotRaw < 1) + { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) + { + return null; + } + } + else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) + { + return null; + } + + if (stackInSlot.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return te.isUseableByPlayer(player); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java new file mode 100644 index 0000000000..dcf8da3a1a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/GUI_FrameHousing.java @@ -0,0 +1,49 @@ +package gtPlusPlus.xmod.forestry.bees.alveary.gui; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +public class GUI_FrameHousing extends GuiContainer +{ + private ResourceLocation texture = new ResourceLocation(CORE.MODID, "textures/gui/machine_Charger.png"); + + private InventoryPlayer inventory; + private TileAlvearyFrameHousing te; + + public GUI_FrameHousing(TileAlvearyFrameHousing te, EntityPlayer player) + { + super(new CONTAINER_FrameHousing(te, player)); + inventory = player.inventory; + this.te = te; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + fontRendererObj.drawString(I18n.format("Alveary Frame Housing"), (xSize / 2) - (fontRendererObj.getStringWidth(I18n.format("Alveary Frame Housing")) / 2), 6, 4210752, false); + fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752); + //fontRendererObj.drawString(I18n.format("Charge:"+te.getCharge()+"~"), 8, ySize - 96 + 2, 4210752); + //fontRendererObj.drawString(I18n.format("Progress:"+te.getProgress()+"ticks"), 80, ySize - 96 + 2, 4210752); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java new file mode 100644 index 0000000000..406c3c47cb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/alveary/gui/InventoryFrameHousing.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.forestry.bees.alveary.gui; + +import net.minecraft.item.ItemStack; +import forestry.api.apiculture.BeeManager; +import forestry.core.inventory.InventoryAdapterTile; +import forestry.core.utils.ItemStackUtil; +import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing; + +public class InventoryFrameHousing extends InventoryAdapterTile<TileAlvearyFrameHousing> +{ + public InventoryFrameHousing(TileAlvearyFrameHousing alvearyFrame) + { + super(alvearyFrame, 1, "FrameHousingInv"); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) + { + return ItemStackUtil.containsItemStack(BeeManager.inducers.keySet(), itemStack); + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_ItemRegistry.java b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_ItemRegistry.java new file mode 100644 index 0000000000..edd04661d7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_ItemRegistry.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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 gtPlusPlus.xmod.forestry.bees.items; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.ChestGenHooks; +import cpw.mods.fml.common.registry.GameRegistry; +import forestry.core.items.ItemBlockForestry; +import forestry.core.utils.StringUtil; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.forestry.bees.alveary.FR_BlockAlveary; + +public class FR_ItemRegistry { + + + //----- Apiary Frames ---------------------- + //public static FR_ItemHiveFrame frameUntreated; + //public static FR_ItemHiveFrame frameImpregnated; + //public static FR_ItemHiveFrame frameProven; + + //Magic Bee Frame Items + public static MB_ItemFrame hiveFrameAccelerated; + public static MB_ItemFrame hiveFrameVoid; + public static MB_ItemFrame hiveFrameMutagenic; + public static MB_ItemFrame haveFrameBusy; + + //Extra Bee Frame Items + public static MB_ItemFrame hiveFrameCocoa; + public static MB_ItemFrame hiveFrameCaged; + public static MB_ItemFrame hiveFrameSoul; + public static MB_ItemFrame hiveFrameClay; + public static MB_ItemFrame hiveFrameNova; + + //Alveary Stuff + public static FR_BlockAlveary alveary; + + public static void Register() { + + //Forestry Frames + //frameUntreated = registerItem(new FR_ItemHiveFrame(80, 0.9f), "frameUntreated"); + //frameImpregnated = registerItem(new FR_ItemHiveFrame(240, 0.4f), "frameImpregnated"); + //frameProven = registerItem(new FR_ItemHiveFrame(720, 0.3f), "frameProven"); + + //Magic Bee like Frames + hiveFrameAccelerated = new MB_ItemFrame(MB_FrameType.ACCELERATED, "Longevity for bees isn't very common."); + hiveFrameVoid = new MB_ItemFrame(MB_FrameType.VOID, EnumRarity.rare, "??? (Dungeon Loot)"); + hiveFrameMutagenic = new MB_ItemFrame(MB_FrameType.MUTAGENIC, EnumRarity.epic, "Evolution of the fitest, finest and fastest."); + haveFrameBusy = new MB_ItemFrame(MB_FrameType.BUSY, "Busy bee, Busy Bee, make more honey please for me."); + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new ItemStack(hiveFrameVoid), 1, 1, 18)); + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new ItemStack(hiveFrameVoid), 1, 3, 23)); + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new ItemStack(hiveFrameMutagenic), 1, 1, 18)); + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new ItemStack(hiveFrameMutagenic), 1, 3, 23)); + + //Extra Bee like Frames + if (!LoadedMods.ExtraBees){ + hiveFrameCocoa = new MB_ItemFrame(MB_FrameType.COCOA, EnumRarity.common, ""); + hiveFrameCaged = new MB_ItemFrame(MB_FrameType.CAGE, EnumRarity.common, ""); + hiveFrameSoul = new MB_ItemFrame(MB_FrameType.SOUL, EnumRarity.common, ""); + hiveFrameClay = new MB_ItemFrame(MB_FrameType.CLAY, EnumRarity.common, ""); + hiveFrameNova = new MB_ItemFrame(MB_FrameType.NOVA, EnumRarity.epic, "A Creative Only Frame."); + if (CORE.configSwitches.enableCustomAlvearyBlocks){ + alveary = registerBlock(new FR_BlockAlveary(), ItemBlockForestry.class, "alveary"); + } + } + + + + + } + + protected static <T extends Item> T registerItem(T item, String name) { + item.setUnlocalizedName(name); + GameRegistry.registerItem(item, StringUtil.cleanItemName(item)); + return item; + } + + protected static <T extends Block> T registerBlock(T block, Class<? extends ItemBlock> itemClass, String name, Object... itemCtorArgs) { + block.setBlockName("for." + name); + GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block), itemCtorArgs); + return block; + } +} + + diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_StringUtil.java b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_StringUtil.java new file mode 100644 index 0000000000..69065bec24 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_StringUtil.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.forestry.bees.items; + +import net.minecraft.util.StatCollector; + +public class FR_StringUtil +{ + public static String getLocalizedString(String key) + { + if(StatCollector.canTranslate(key)) + { + return StatCollector.translateToLocal(key); + } + return StatCollector.translateToFallback(key); + } + + public static String getLocalizedString(String key, Object... objects) + { + if(StatCollector.canTranslate(key)) + { + return String.format(StatCollector.translateToLocal(key), objects); + } + return String.format(StatCollector.translateToFallback(key), objects); + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_FrameType.java b/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_FrameType.java new file mode 100644 index 0000000000..5a61c94196 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_FrameType.java @@ -0,0 +1,119 @@ +package gtPlusPlus.xmod.forestry.bees.items; + +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeModifier; + +public enum MB_FrameType implements IBeeModifier +{ + //ExtraBees Clone Frames + //Name, FrameHP, territory (1f), Mutation rate, lifespan rate, production rate, genetic decay (1f) + COCOA("Chocolate", 240, 1.0f, 1.0f, 0.50f, 1.50f, 1f), + CAGE("Restraint", 240, 0.5f, 1.0f, 0.75f, 0.75f, 1f), + SOUL("Soul", 80, 1.0f, 1.5f, 0.75f, 0.25f, 1f), + CLAY("Healing", 240, 1.0f, 0.5f, 1.50f, 0.75f, 1f), + NOVA("Nova", 240, 1.0f, 100.0f, 0.0001f, 1.00f, 1f), + + + //Name, FrameHP, territory (1f), Mutation rate, lifespan rate, production rate, genetic decay (1f) + ACCELERATED("Accelerated", 175, 1f, 2.5f, 0.9f, 1.8f, 1f), + VOID("Void", 20, 1f, 1f, 0.0001f, 10f, 1f), + MUTAGENIC("Mutagenic", 3, 1f, 10f, 0.0001f, 10f, 1f), + BUSY("Busy", 2000, 1f, 0f, 3f, 4f, 1f); + + private final String frameName; + public final int maxDamage; + + private final float territoryMod; + private final float mutationMod; + private final float lifespanMod; + private final float productionMod; + private final float floweringMod; + private final float geneticDecayMod; + private final boolean isSealed; + private final boolean isLit; + private final boolean isSunlit; + private final boolean isHellish; + + MB_FrameType(String name, int damage, float territory, float mutation, float lifespan, float production, float geneticDecay) { + this(name, damage, territory, mutation, lifespan, production, 1f, geneticDecay, false, false, false, false); + } + + MB_FrameType(String name, int damage, + float territory, float mutation, float lifespan, float production, float flowering, float geneticDecay, + boolean sealed, boolean lit, boolean sunlit, boolean hellish) + { + this.frameName = name; + this.maxDamage = damage; + + this.territoryMod = territory; + this.mutationMod = mutation; + this.lifespanMod = lifespan; + this.productionMod = production; + this.floweringMod = flowering; + this.geneticDecayMod = geneticDecay; + this.isSealed = sealed; + this.isLit = lit; + this.isSunlit = sunlit; + this.isHellish = hellish; + } + + public String getName() + { + return this.frameName; + } + + public String getLocalizedName() + { + return FR_StringUtil.getLocalizedString("frame." + this.frameName); + } + + @Override + public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { + return territoryMod; + } + + @Override + public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return mutationMod; + } + + @Override + public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return lifespanMod; + } + + @Override + public float getProductionModifier(IBeeGenome genome, float currentModifier) { + return productionMod; + } + + @Override + public float getFloweringModifier(IBeeGenome genome, float currentModifier) { + return floweringMod; + } + + @Override + public float getGeneticDecay(IBeeGenome genome, float currentModifier) { + return geneticDecayMod; + } + + @Override + public boolean isSealed() { + return isSealed; + } + + @Override + public boolean isSelfLighted() { + return isLit; + } + + @Override + public boolean isSunlightSimulated() { + return isSunlit; + } + + @Override + public boolean isHellish() { + return isHellish; + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_ItemFrame.java b/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_ItemFrame.java new file mode 100644 index 0000000000..0f0e7d3109 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/items/MB_ItemFrame.java @@ -0,0 +1,140 @@ +package gtPlusPlus.xmod.forestry.bees.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.apiculture.IBee; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IBeeModifier; +import forestry.api.apiculture.IHiveFrame; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; + +public class MB_ItemFrame extends Item implements IHiveFrame +{ + private MB_FrameType type; + private EnumRarity rarity_value = EnumRarity.uncommon; + private final String toolTip; + + public MB_ItemFrame(MB_FrameType frameType, String description) + { + this(frameType, EnumRarity.uncommon, description); + } + + public MB_ItemFrame(MB_FrameType frameType, EnumRarity rarity, String description) + { + super(); + this.type = frameType; + this.setMaxDamage(this.type.maxDamage); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName("frame" + frameType.getName()); + this.rarity_value = rarity; + this.toolTip = description; + GameRegistry.registerItem(this, "frame" + frameType.getName()); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + if (toolTip != "" || !toolTip.equals("")){ + list.add(EnumChatFormatting.GRAY+toolTip); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(CORE.MODID + ":frame" + type.getName()); + } + + // --------- IHiveFrame functions ----------------------------------------- + + @Override + public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) { + frame.setItemDamage(frame.getItemDamage() + wear); + + if (frame.getItemDamage() >= frame.getMaxDamage()) { + // Break the frame. + frame = null; + } + + return frame; + } + + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return rarity_value; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + if (rarity_value == EnumRarity.uncommon || rarity_value == EnumRarity.common){ + return false; + } + return true; + } + + public IBeeModifier getBeeModifier() { + return type; + } + + @Override + public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) + { + return false; + } + + public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { + return type.getTerritoryModifier(genome, currentModifier); + } + + public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return type.getMutationModifier(genome, mate, currentModifier); + } + + public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return type.getLifespanModifier(genome, mate, currentModifier); + } + + public float getProductionModifier(IBeeGenome genome, float currentModifier) { + return type.getProductionModifier(genome, currentModifier); + } + + public float getFloweringModifier(IBeeGenome genome, float currentModifier) { + return type.getFloweringModifier(genome, currentModifier); + } + + public float getGeneticDecay(IBeeGenome genome, float currentModifier) { + return type.getGeneticDecay(genome, currentModifier); + } + + public boolean isSealed() { + return type.isSealed(); + } + + public boolean isSelfLighted() { + return type.isSelfLighted(); + } + + public boolean isSunlightSimulated() { + return type.isSunlightSimulated(); + } + + public boolean isHellish(){ + return type.isHellish(); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java new file mode 100644 index 0000000000..95049df43b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java @@ -0,0 +1,82 @@ +package gtPlusPlus.xmod.forestry.bees.recipe; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class FR_Gregtech_Recipes { + + private static String rod_ElectrumFlux = "stickElectrumFlux"; + private static String rod_LongElectrumFlux = "stickLongElectrumFlux"; + private static String foil_Electrum = "foilElectrum"; + private static String rod_Uranium = "stickUranium"; + private static String rod_LongUranium = "stickLongUranium"; + private static String foil_Uranium235 = "foilUranium235"; + private static ItemStack hiveFrameAccelerated = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameAccelerated); + private static ItemStack hiveFrameMutagenic = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameMutagenic); + + + private static ItemStack hiveFrameCocoa = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameCocoa); + private static ItemStack hiveFrameCaged = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameCaged); + private static ItemStack hiveFrameSoul = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameSoul); + private static ItemStack hiveFrameClay = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameClay); + private static ItemStack hiveFrameNova = UtilsItems.getSimpleStack(FR_ItemRegistry.hiveFrameNova); + + private static ItemStack hiveFrameImpregnated = UtilsItems.getItemStack("Forestry:frameImpregnated", 1); + private static ItemStack blockSoulSand = new ItemStack(Blocks.soul_sand, 1); + private static ItemStack blockIronBars = new ItemStack (Blocks.iron_bars, 1); + private static ItemStack itemClayDust = new ItemStack(Items.clay_ball, 1); + private static ItemStack itemCocoaBeans = new ItemStack(Items.dye, 1, 3); + + + public static void registerItems(){ + + //Magic Bee Like Frames + UtilsRecipe.recipeBuilder( + rod_LongElectrumFlux, rod_ElectrumFlux, rod_LongElectrumFlux, + rod_LongElectrumFlux, foil_Electrum, rod_LongElectrumFlux, + rod_ElectrumFlux, rod_ElectrumFlux, rod_ElectrumFlux, + hiveFrameAccelerated); + + UtilsRecipe.recipeBuilder( + rod_LongUranium, rod_Uranium, rod_LongUranium, + rod_LongUranium, foil_Uranium235, rod_LongUranium, + rod_Uranium, rod_Uranium, rod_Uranium, + hiveFrameMutagenic); + + if (!LoadedMods.ExtraBees){ + //Extra Bee Like Frames + UtilsRecipe.recipeBuilder( + null, itemCocoaBeans, null, + itemCocoaBeans, hiveFrameImpregnated, itemCocoaBeans, + null, itemCocoaBeans, null, + hiveFrameCocoa); + + UtilsRecipe.recipeBuilder( + hiveFrameImpregnated, blockIronBars, null, + null, null, null, + null, null, null, + hiveFrameCaged); + + UtilsRecipe.recipeBuilder( + hiveFrameImpregnated, blockSoulSand, null, + null, null, null, + null, null, null, + hiveFrameSoul); + + UtilsRecipe.recipeBuilder( + null, itemClayDust, null, + itemClayDust, hiveFrameImpregnated, itemClayDust, + null, itemClayDust, null, + hiveFrameClay); + } + + + + } + +} |