diff --git a/.gitignore b/.gitignore index adab173..de81a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,7 @@ libs/ config/ crash-reports/ logs/ -mods/ \ No newline at end of file +mods/ +saves/ +usernamecache.json +options.txt \ No newline at end of file diff --git a/build.gradle b/build.gradle index f1f9623..ee5a5ff 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,7 @@ archivesBaseName = "magicbees" minecraft { version = project.version_mc + "-" + project.version_forge assetDir = "eclipse/assets" + runDir = "." replace '@VERSION@', project.version_mod replace '@MCVERSION@', project.version_mc diff --git a/gradle.properties b/gradle.properties index 740d480..76d1e9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ version_major=2 -version_minor=1 -version_rev=31 +version_minor=2 +version_rev=0 version_forestry=3.4.0.7 version_bloodmagic=1.3.1-7 version_mc=1.7.10 -version_forge=10.13.2.1230 \ No newline at end of file +version_forge=10.13.2.1230 diff --git a/src/main/java/magicbees/api/bees/IAuraChargeType.java b/src/main/java/magicbees/api/bees/IAuraChargeType.java new file mode 100644 index 0000000..72387b3 --- /dev/null +++ b/src/main/java/magicbees/api/bees/IAuraChargeType.java @@ -0,0 +1,4 @@ +package magicbees.api.bees; + +public interface IAuraChargeType { +} diff --git a/src/main/java/magicbees/api/bees/IMagicApiaryAuraProvider.java b/src/main/java/magicbees/api/bees/IMagicApiaryAuraProvider.java new file mode 100644 index 0000000..1993b44 --- /dev/null +++ b/src/main/java/magicbees/api/bees/IMagicApiaryAuraProvider.java @@ -0,0 +1,46 @@ +package magicbees.api.bees; + +/** + * Allows a tile entity to provide a Magic Apiary with 'aura' to boost bee production, mutation rate, + * or decrease bee lifespan. + * + * @author MysteriousAges + */ +public interface IMagicApiaryAuraProvider { + + /** + * Requests a mutation charge from the aura provider. If true is returned, the + * aura provider should decrement its internal charge by one. If there are no + * charges remaining, it should return false. + * + * @return True if a charge is given; false otherwise. + */ + boolean getMutationCharge(); + + /** + * Requests a mutation charge from the aura provider. If true is returned, the + * aura provider should decrement its internal charge by one. If there are no + * charges remaining, it should return false. + * + * @return True if a charge is given; false otherwise. + */ + boolean getDeathRateCharge(); + + /** + * Requests a mutation charge from the aura provider. If true is returned, the + * aura provider should decrement its internal charge by one. If there are no + * charges remaining, it should return false. + * + * @return True if a charge is given; false otherwise. + */ + boolean getProductionCharge(); + + /** + * Requests a mutation charge from the aura provider. If true is returned, the + * aura provider should decrement its internal charge by one. If there are no + * charges remaining, it should return false. + * + * @return True if a charge is given; false otherwise. + */ + boolean getCharge(IAuraChargeType auraChargeType); +} diff --git a/src/main/java/magicbees/bees/AuraChargeType.java b/src/main/java/magicbees/bees/AuraChargeType.java new file mode 100644 index 0000000..f811d4d --- /dev/null +++ b/src/main/java/magicbees/bees/AuraChargeType.java @@ -0,0 +1,22 @@ +package magicbees.bees; + +import magicbees.api.bees.IAuraChargeType; +import thaumcraft.api.aspects.Aspect; + +public enum AuraChargeType implements IAuraChargeType { + MUTATION(Aspect.WATER, 850, 11), + DEATH(Aspect.ENTROPY, 400, 5), + PRODUCTION(Aspect.AIR, 300, 3); + + public final int duration; + public final Aspect aspect; + /** The number of ticks to count between draining vis from the environment **/ + public final int tickRate; + public final int flag = 1 << ordinal(); + + AuraChargeType(Aspect aspect, int duration, int tickRate) { + this.aspect = aspect; + this.duration = duration; + this.tickRate = tickRate; + } +} diff --git a/src/main/java/magicbees/bees/BeeSpecies.java b/src/main/java/magicbees/bees/BeeSpecies.java index b566790..8d00d42 100644 --- a/src/main/java/magicbees/bees/BeeSpecies.java +++ b/src/main/java/magicbees/bees/BeeSpecies.java @@ -6,9 +6,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import magicbees.item.types.CombType; import magicbees.item.types.DropType; import magicbees.item.types.NuggetType; @@ -32,6 +29,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; + +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -42,7 +44,9 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IIconProvider; import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleTolerance; import forestry.api.genetics.IClassification; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IMutation; @@ -1250,7 +1254,7 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider int highest = 0; excludeSpecies.add(species); - for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) + for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { if (!excludeSpecies.contains(mutation.getAllele0())) { @@ -1417,6 +1421,20 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider return value; } + + public boolean canWorkInTemperature(EnumTemperature temp) { + IAlleleTolerance tolerance = (IAlleleTolerance)genomeTemplate[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()]; + return AlleleManager.climateHelper.isWithinLimits(temp, EnumHumidity.NORMAL, + temperature, tolerance.getValue(), + EnumHumidity.NORMAL, EnumTolerance.NONE); + } + + public boolean canWorkInHumidity(EnumHumidity humid) { + IAlleleTolerance tolerance = (IAlleleTolerance)genomeTemplate[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()]; + return AlleleManager.climateHelper.isWithinLimits(EnumTemperature.NORMAL, humid, + EnumTemperature.NORMAL, EnumTolerance.NONE, + humidity, tolerance.getValue()); + } /// --------- Unused Functions --------------------------------------------- diff --git a/src/main/java/magicbees/bees/HiveDescription.java b/src/main/java/magicbees/bees/HiveDescription.java index 2252131..4d6d85c 100644 --- a/src/main/java/magicbees/bees/HiveDescription.java +++ b/src/main/java/magicbees/bees/HiveDescription.java @@ -185,13 +185,13 @@ public enum HiveDescription implements IHiveDescription { @Override public boolean isGoodHumidity(EnumHumidity humidity) { - return true; + return hiveType.getOccupant().canWorkInHumidity(humidity); } @Override public boolean isGoodTemperature(EnumTemperature temperature) { - return true; + return hiveType.getOccupant().canWorkInTemperature(temperature); } @Override diff --git a/src/main/java/magicbees/block/BlockThaumicApiary.java b/src/main/java/magicbees/block/BlockMagicApiary.java similarity index 93% rename from src/main/java/magicbees/block/BlockThaumicApiary.java rename to src/main/java/magicbees/block/BlockMagicApiary.java index 437e364..fba29bf 100644 --- a/src/main/java/magicbees/block/BlockThaumicApiary.java +++ b/src/main/java/magicbees/block/BlockMagicApiary.java @@ -6,7 +6,7 @@ import magicbees.client.gui.UIScreens; import magicbees.main.CommonProxy; import magicbees.main.MagicBees; import magicbees.main.utils.TabMagicBees; -import magicbees.tileentity.TileEntityThaumicApiary; +import magicbees.tileentity.TileEntityMagicApiary; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -21,16 +21,16 @@ import net.minecraft.world.World; import javax.swing.*; -public class BlockThaumicApiary extends BlockContainer +public class BlockMagicApiary extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon[] icons; - public BlockThaumicApiary() + public BlockMagicApiary() { super(Material.wood); this.setCreativeTab(TabMagicBees.tabMagicBees); - this.setBlockName("thaumicApiary"); + this.setBlockName("magicApiary"); this.setHardness(1f); this.setResistance(1.5f); this.setHarvestLevel("axe", 0); @@ -79,7 +79,7 @@ public class BlockThaumicApiary extends BlockContainer @Override public TileEntity createNewTileEntity(World world, int metadata) { - return new TileEntityThaumicApiary(); + return new TileEntityMagicApiary(); } @Override diff --git a/src/main/java/magicbees/block/BlockVisAuraProvider.java b/src/main/java/magicbees/block/BlockVisAuraProvider.java new file mode 100644 index 0000000..bdb0a4e --- /dev/null +++ b/src/main/java/magicbees/block/BlockVisAuraProvider.java @@ -0,0 +1,49 @@ +package magicbees.block; + +import magicbees.main.CommonProxy; +import magicbees.main.utils.TabMagicBees; +import magicbees.tileentity.TileEntityVisAuraProvider; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockVisAuraProvider extends BlockContainer { + + public BlockVisAuraProvider() { + super(Material.glass); + this.setCreativeTab(TabMagicBees.tabMagicBees); + this.setBlockName("visAuraProvider"); + this.setHardness(0.5f); + this.setResistance(1.5f); + this.setLightLevel(8); + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata) { + return new TileEntityVisAuraProvider(); + } + + @Override + public int getRenderType() + { + return CommonProxy.RenderIdVisAuraProvider; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = Blocks.planks.getIcon(0, 5); + } + +} diff --git a/src/main/java/magicbees/block/types/HiveType.java b/src/main/java/magicbees/block/types/HiveType.java index 584d2a3..c9eea00 100644 --- a/src/main/java/magicbees/block/types/HiveType.java +++ b/src/main/java/magicbees/block/types/HiveType.java @@ -2,17 +2,6 @@ package magicbees.block.types; import java.util.ArrayList; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.apiculture.IHiveDrop; - import magicbees.bees.BeeGenomeManager; import magicbees.bees.BeeSpecies; import magicbees.bees.HiveDrop; @@ -20,20 +9,29 @@ import magicbees.item.types.CombType; import magicbees.main.CommonProxy; import magicbees.main.Config; import magicbees.main.utils.compat.ForestryHelper; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.apiculture.IHiveDrop; public enum HiveType { - CURIOUS("curious", 12, true), - UNUSUAL("unusual", 12, true), - RESONANT("resonant", 12, true), - DEEP("deep", 4, false), - INFERNAL("infernal", 15, false), - OBLIVION("oblivion", 7, false), + CURIOUS("curious", BeeSpecies.MYSTICAL, 12, true), + UNUSUAL("unusual", BeeSpecies.UNUSUAL, 12, true), + RESONANT("resonant", BeeSpecies.SORCEROUS, 12, true), + DEEP("deep", BeeSpecies.ATTUNED, 4, false), + INFERNAL("infernal", BeeSpecies.INFERNAL, 15, false), + OBLIVION("oblivion", BeeSpecies.OBLIVION, 7, false), ; private static String[] nameList; private String name; + private BeeSpecies occupant; public boolean show; private int lightLevel; private ArrayList drops; @@ -85,9 +83,10 @@ public enum HiveType OBLIVION.drops.add(new HiveDrop(ForestryHelper.getTemplateForestryForSpecies("Steadfast"), combs, 9)); } - private HiveType(String hiveName, int light, boolean visible) + private HiveType(String hiveName, BeeSpecies occupant, int light, boolean visible) { this.name = hiveName; + this.occupant = occupant; this.lightLevel = light; this.show = visible; this.drops = new ArrayList(); @@ -173,6 +172,10 @@ public enum HiveType return (nameList == null) ? nameList = generateNames() : nameList; } + public BeeSpecies getOccupant() { + return this.occupant; + } + private static String[] generateNames() { String[] names = new String[values().length]; diff --git a/src/main/java/magicbees/client/gui/ContainerMB.java b/src/main/java/magicbees/client/gui/ContainerMB.java index e3f7e5e..e608cf7 100644 --- a/src/main/java/magicbees/client/gui/ContainerMB.java +++ b/src/main/java/magicbees/client/gui/ContainerMB.java @@ -13,12 +13,12 @@ public class ContainerMB extends Container public void addPlayerInventory(InventoryPlayer inventoryPlayer, int xStart, int yStart) { for (int x = 0; x < PLAYER_INVENTORY_COLUMNS; x++){ - addSlotToContainer(new Slot(inventoryPlayer, x, 8 + 18 * x, yStart + 4 + PLAYER_INVENTORY_ROWS * 18)); + addSlotToContainer(new Slot(inventoryPlayer, x, xStart + 8 + 18 * x, yStart + 4 + PLAYER_INVENTORY_ROWS * 18)); } for (int y = 0; y < PLAYER_INVENTORY_ROWS; y++){ for (int x = 0; x < PLAYER_INVENTORY_COLUMNS; x++){ - addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, 8 + 18 * x, yStart + y * 18)); + addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, xStart + 8 + 18 * x, yStart + y * 18)); } } } diff --git a/src/main/java/magicbees/client/gui/ContainerThaumicApiary.java b/src/main/java/magicbees/client/gui/ContainerMagicApiary.java similarity index 80% rename from src/main/java/magicbees/client/gui/ContainerThaumicApiary.java rename to src/main/java/magicbees/client/gui/ContainerMagicApiary.java index 81783cd..92fe6d5 100644 --- a/src/main/java/magicbees/client/gui/ContainerThaumicApiary.java +++ b/src/main/java/magicbees/client/gui/ContainerMagicApiary.java @@ -3,16 +3,16 @@ package magicbees.client.gui; import forestry.api.apiculture.IHiveFrame; import forestry.plugins.PluginApiculture; import magicbees.main.utils.ItemInterface; -import magicbees.tileentity.TileEntityThaumicApiary; +import magicbees.tileentity.TileEntityMagicApiary; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerThaumicApiary extends ContainerMB { +public class ContainerMagicApiary extends ContainerMB { - private TileEntityThaumicApiary thaumicApiary; + public TileEntityMagicApiary apiary; public int maxSlot = 0; // Constants @@ -23,13 +23,13 @@ public class ContainerThaumicApiary extends ContainerMB { private static final int SLOT_FRAME_COUNT = 3; private static final int SLOT_INVENTORY_COUNT = 7; - public ContainerThaumicApiary(InventoryPlayer inventoryPlayer, TileEntityThaumicApiary thaumicApiary){ - this.thaumicApiary = thaumicApiary; + public ContainerMagicApiary(InventoryPlayer inventoryPlayer, TileEntityMagicApiary thaumicApiary){ + this.apiary = thaumicApiary; // Queen/Princess slot - addSlotToContainer(new SlotCustomItems(this.thaumicApiary, 0, 29, 39, ItemInterface.getItemStack("Forestry", "beeQueenGE", 1), ItemInterface.getItemStack("Forestry", "beePrincessGE", 1))); + addSlotToContainer(new SlotCustomItems(this.apiary, 0, 29, 39, ItemInterface.getItemStack("Forestry", "beeQueenGE", 1), ItemInterface.getItemStack("Forestry", "beePrincessGE", 1))); // Drone slot - addSlotToContainer(new SlotCustomItems(this.thaumicApiary, 1, 29, 65, ItemInterface.getItemStack("Forestry", "beeDroneGE", 64))); + addSlotToContainer(new SlotCustomItems(this.apiary, 1, 29, 65, ItemInterface.getItemStack("Forestry", "beeDroneGE", 64))); int currentSlot = 1; @@ -56,7 +56,7 @@ public class ContainerThaumicApiary extends ContainerMB { j++; } - addPlayerInventory(inventoryPlayer, 0, 108); + addPlayerInventory(inventoryPlayer, 0, 110); maxSlot = currentSlot; @@ -105,13 +105,13 @@ public class ContainerThaumicApiary extends ContainerMB { @Override public boolean canInteractWith(EntityPlayer entityPlayer) { - return thaumicApiary.isUseableByPlayer(entityPlayer); + return apiary.isUseableByPlayer(entityPlayer); } @Override public void updateProgressBar(int i, int j) { - thaumicApiary.getGUINetworkData(i, j); + apiary.getGUINetworkData(i, j); } @Override @@ -119,7 +119,7 @@ public class ContainerThaumicApiary extends ContainerMB { super.detectAndSendChanges(); for (Object crafter : crafters) { - thaumicApiary.sendGUINetworkData(this, (ICrafting) crafter); + apiary.sendGUINetworkData(this, (ICrafting) crafter); } } } diff --git a/src/main/java/magicbees/client/gui/GUIHandler.java b/src/main/java/magicbees/client/gui/GUIHandler.java index 47a3496..16e84fc 100644 --- a/src/main/java/magicbees/client/gui/GUIHandler.java +++ b/src/main/java/magicbees/client/gui/GUIHandler.java @@ -1,7 +1,7 @@ package magicbees.client.gui; import magicbees.tileentity.TileEntityEffectJar; -import magicbees.tileentity.TileEntityThaumicApiary; +import magicbees.tileentity.TileEntityMagicApiary; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -21,8 +21,8 @@ public class GUIHandler implements IGuiHandler } else if (ID == UIScreens.THAUMIC_APIARY.ordinal()) { - TileEntityThaumicApiary tileEntityThaumicApiary = (TileEntityThaumicApiary) world.getTileEntity(x, y, z); - value = new ContainerThaumicApiary(player.inventory, tileEntityThaumicApiary); + TileEntityMagicApiary tileEntityThaumicApiary = (TileEntityMagicApiary) world.getTileEntity(x, y, z); + value = new ContainerMagicApiary(player.inventory, tileEntityThaumicApiary); } return value; @@ -38,8 +38,8 @@ public class GUIHandler implements IGuiHandler value = new GUIEffectJar((TileEntityEffectJar)world.getTileEntity(x, y, z), player); }else if (ID == UIScreens.THAUMIC_APIARY.ordinal()) { - TileEntityThaumicApiary tileEntityThaumicApiary = (TileEntityThaumicApiary) world.getTileEntity(x, y, z); - value = new GuiThaumicApiary(player.inventory, tileEntityThaumicApiary); + TileEntityMagicApiary tileEntityThaumicApiary = (TileEntityMagicApiary) world.getTileEntity(x, y, z); + value = new GuiMagicApiary(player.inventory, tileEntityThaumicApiary); } return value; diff --git a/src/main/java/magicbees/client/gui/GuiMagicApiary.java b/src/main/java/magicbees/client/gui/GuiMagicApiary.java new file mode 100644 index 0000000..2b39482 --- /dev/null +++ b/src/main/java/magicbees/client/gui/GuiMagicApiary.java @@ -0,0 +1,143 @@ +package magicbees.client.gui; + +import magicbees.main.CommonProxy; +import magicbees.tileentity.TileEntityMagicApiary; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiMagicApiary extends GuiContainer +{ + public static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.GUI_TEXTURE + "apiary.png"); + + private static final int WIDTH = 176; + private static final int HEIGHT = 190; + + private static final int LIFEBAR_WIDTH = 2; + private static final int LIFEBAR_HEIGHT = 46; + + private static final int LIFEBAR_DEST_X = 21; + private static final int LIFEBAR_DEST_Y = 37; + + private static final int LIFEBAR_SRC_Y = 0; + private static final int LIFEBAR_SRC_STAGE1_X = 184; + private static final int LIFEBAR_SRC_STAGE2_X = 182; + private static final int LIFEBAR_SRC_STAGE3_X = 180; + private static final int LIFEBAR_SRC_STAGE4_X = 178; + private static final int LIFEBAR_SRC_STAGE5_X = 176; + + private static final int WORKBOOST_WIDTH = 16; + private static final int WORKBOOST_HEIGHT = 12; + private static final int WORKBOOST_DEST_X = 37; + private static final int WORKBOOST_DEST_Y = 18; + private static final int WORKBOOST_SRC_X = 176; + private static final int WORKBOOST_SRC_Y = 46; + + private static final int DEATHBOOST_WIDTH = 11; + private static final int DEATHBOOST_HEIGHT = 13; + private static final int DEATHBOOST_DEST_X = 25; + private static final int DEATHBOOST_DEST_Y = 17; + private static final int DEATHBOOST_SRC_X = 176; + private static final int DEATHBOOST_SRC_Y = 58; + + private static final int MUTATIONBOOST_WIDTH = 9; + private static final int MUTATIONBOOST_HEIGHT = 13; + private static final int MUTATIONBOOST_DEST_X = 15; + private static final int MUTATIONBOOST_DEST_Y = 17; + private static final int MUTATIONBOOST_SRC_X = 176; + private static final int MUTATIONBOOST_SRC_Y = 71; + + private GuiButton mutationButton; + + public GuiMagicApiary(InventoryPlayer inventoryPlayer, TileEntityMagicApiary thaumicApiary) { + super(new ContainerMagicApiary(inventoryPlayer, thaumicApiary)); + + this.xSize = WIDTH; + this.ySize = HEIGHT; + + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + fontRendererObj.drawString("Inventory", 9, 99, 0); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { + GL11.glColor4f(1, 1, 1, 1); + this.mc.getTextureManager().bindTexture(BACKGROUND_LOCATION); + + this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + TileEntityMagicApiary apiary = ((ContainerMagicApiary)this.inventorySlots).apiary; + + drawLifebar(apiary); + + drawWorkBoostIcon(apiary); + drawDeathRateIcon(apiary); + drawMutationIcon(apiary); + } + + private void drawMutationIcon(TileEntityMagicApiary apiary) { + if (apiary.isMutationBoosted()) { + this.drawTexturedModalRect(this.guiLeft + MUTATIONBOOST_DEST_X, this.guiTop + MUTATIONBOOST_DEST_Y, + MUTATIONBOOST_SRC_X, MUTATIONBOOST_SRC_Y, MUTATIONBOOST_WIDTH, MUTATIONBOOST_HEIGHT); + } + } + + private void drawDeathRateIcon(TileEntityMagicApiary apiary) { + if (apiary.isDeathRateBoosted()) { + this.drawTexturedModalRect(this.guiLeft + DEATHBOOST_DEST_X, this.guiTop + DEATHBOOST_DEST_Y, + DEATHBOOST_SRC_X, DEATHBOOST_SRC_Y, DEATHBOOST_WIDTH, DEATHBOOST_HEIGHT); + } + } + + private void drawWorkBoostIcon(TileEntityMagicApiary apiary) { + if (apiary.isProductionBoosted()) { + this.drawTexturedModalRect(this.guiLeft + WORKBOOST_DEST_X, this.guiTop + WORKBOOST_DEST_Y, + WORKBOOST_SRC_X, WORKBOOST_SRC_Y, WORKBOOST_WIDTH, WORKBOOST_HEIGHT); + } + } + + private void drawLifebar(TileEntityMagicApiary apiary) { + int value = LIFEBAR_HEIGHT - apiary.getHealthScaled(LIFEBAR_HEIGHT); + int lifebarSrc = getLifebarSrc(apiary); + this.drawTexturedModalRect(this.guiLeft + LIFEBAR_DEST_X, this.guiTop + value + LIFEBAR_DEST_Y, + lifebarSrc, LIFEBAR_SRC_Y, LIFEBAR_WIDTH, LIFEBAR_HEIGHT - value); + } + + private int getLifebarSrc(TileEntityMagicApiary apiary) { + int value = apiary.getHealthScaled(5); + if (value >= 5) { + return LIFEBAR_SRC_STAGE1_X; + } + else if (value >= 4) { + return LIFEBAR_SRC_STAGE2_X; + } + else if (value >= 3) { + return LIFEBAR_SRC_STAGE3_X; + } + else if (value >= 2) { + return LIFEBAR_SRC_STAGE4_X; + } + else { + return LIFEBAR_SRC_STAGE5_X; + } + } + + @Override + protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) { + // TODO Auto-generated method stub + super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); + } +} diff --git a/src/main/java/magicbees/client/gui/GuiThaumicApiary.java b/src/main/java/magicbees/client/gui/GuiThaumicApiary.java deleted file mode 100644 index 01a647b..0000000 --- a/src/main/java/magicbees/client/gui/GuiThaumicApiary.java +++ /dev/null @@ -1,36 +0,0 @@ -package magicbees.client.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import magicbees.main.CommonProxy; -import magicbees.tileentity.TileEntityThaumicApiary; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GuiThaumicApiary extends GuiContainer -{ - public static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.GUI_TEXTURE + "apiary.png"); - - private static final int WIDTH = 176; - private static final int HEIGHT = 190; - - public GuiThaumicApiary(InventoryPlayer inventoryPlayer, TileEntityThaumicApiary thaumicApiary) { - super(new ContainerThaumicApiary(inventoryPlayer, thaumicApiary)); - - this.xSize = WIDTH; - this.ySize = HEIGHT; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { - GL11.glColor4f(1, 1, 1, 1); - this.mc.getTextureManager().bindTexture(BACKGROUND_LOCATION); - - this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - } -} diff --git a/src/main/java/magicbees/client/model/ModelEffectJar.java b/src/main/java/magicbees/client/model/ModelEffectJar.java index e33ceb2..0db2696 100644 --- a/src/main/java/magicbees/client/model/ModelEffectJar.java +++ b/src/main/java/magicbees/client/model/ModelEffectJar.java @@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class ModelEffectJar { - public static final String objFile = CommonProxy.MODEL_PATH + "effectJar.obj"; + public static final ResourceLocation objFile = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.MODEL + "effectJar.obj"); public static final ResourceLocation textureLocation = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.MODEL + "jarTexture.png"); public static final ModelEffectJar model = new ModelEffectJar(); @@ -20,7 +20,7 @@ public class ModelEffectJar public ModelEffectJar() { - this.effectJarObj = AdvancedModelLoader.loadModel(new ResourceLocation("magicbees", "model/effectJar.obj")); + this.effectJarObj = AdvancedModelLoader.loadModel(objFile); } public void render() diff --git a/src/main/java/magicbees/client/model/ModelVisAuraProvider.java b/src/main/java/magicbees/client/model/ModelVisAuraProvider.java new file mode 100644 index 0000000..a64a0f7 --- /dev/null +++ b/src/main/java/magicbees/client/model/ModelVisAuraProvider.java @@ -0,0 +1,40 @@ +package magicbees.client.model; + +import org.lwjgl.opengl.GL11; + +import magicbees.main.CommonProxy; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelVisAuraProvider { + public static final ResourceLocation objFile = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.MODEL + "visAuraConverter.obj"); + public static final ResourceLocation textureLocation = new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.MODEL + "visAuraProvider.png"); + + public static final ModelVisAuraProvider model = new ModelVisAuraProvider(); + + private IModelCustom visAuraProviderObj; + + public ModelVisAuraProvider() { + this.visAuraProviderObj = AdvancedModelLoader.loadModel(objFile); + } + + public void render(long tick) { + GL11.glPushMatrix(); + GL11.glRotated(Math.sin(tick * Math.PI * 2 / 80) * 0.7, 0, 1, 0); + GL11.glRotated(Math.sin((tick + 25) * Math.PI * 2 / 150) * 0.75, 0.5, 0, 0.5); + GL11.glTranslated(Math.sin(tick * Math.PI * 2 / 1000) * 0.025, 0, Math.sin((tick + 30) * Math.PI * 2 / 650) * 0.03); + float red = (float)(Math.sin(tick * Math.PI * 2 / 130) * 0.2 + 0.8); + float green = (float)(Math.cos((tick + 2) * Math.PI * 2 / 140) * 0.2 + 0.8); + float blue = (float)(Math.sin((tick + 5) * Math.PI * 2 / 99) * 0.2 + 0.8); + GL11.glColor3f(red, green, blue); + this.visAuraProviderObj.renderPart("centre"); + GL11.glPopMatrix(); + + GL11.glColor3f(1f, 1f, 1f); + this.visAuraProviderObj.renderPart("frame"); + } +} diff --git a/src/main/java/magicbees/client/render/EffectJarRenderer.java b/src/main/java/magicbees/client/render/RendererEffectJar.java similarity index 92% rename from src/main/java/magicbees/client/render/EffectJarRenderer.java rename to src/main/java/magicbees/client/render/RendererEffectJar.java index 79ad4bf..c28b24f 100644 --- a/src/main/java/magicbees/client/render/EffectJarRenderer.java +++ b/src/main/java/magicbees/client/render/RendererEffectJar.java @@ -9,9 +9,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; -public class EffectJarRenderer extends TileEntitySpecialRenderer implements IItemRenderer +public class RendererEffectJar extends TileEntitySpecialRenderer implements IItemRenderer { - public static EffectJarRenderer instance = new EffectJarRenderer(); + public static RendererEffectJar instance = new RendererEffectJar(); @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) diff --git a/src/main/java/magicbees/client/render/RendererVisAuraProvider.java b/src/main/java/magicbees/client/render/RendererVisAuraProvider.java new file mode 100644 index 0000000..75353e6 --- /dev/null +++ b/src/main/java/magicbees/client/render/RendererVisAuraProvider.java @@ -0,0 +1,50 @@ +package magicbees.client.render; + +import magicbees.client.model.ModelVisAuraProvider; +import magicbees.tileentity.TileEntityVisAuraProvider; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; + +public class RendererVisAuraProvider extends TileEntitySpecialRenderer implements IItemRenderer { + public static RendererVisAuraProvider instance = new RendererVisAuraProvider(); + + @Override + public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float tick) { + if (entity instanceof TileEntityVisAuraProvider) { + this.doRender(x, y, z, 1f, entity.getWorldObj().getTotalWorldTime()); + } + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + doRender(0, 0, 0, 1f, 0); + } + + private void doRender(double x, double y, double z, float scale, long tick) { + GL11.glPushMatrix(); + GL11.glScaled(scale, scale, scale); + GL11.glTranslated(x, y, z); + + FMLClientHandler.instance().getClient().renderEngine.bindTexture(ModelVisAuraProvider.textureLocation); + ModelVisAuraProvider.model.render(tick); + + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/magicbees/main/ClientProxy.java b/src/main/java/magicbees/main/ClientProxy.java index 911c554..f8f9c2e 100644 --- a/src/main/java/magicbees/main/ClientProxy.java +++ b/src/main/java/magicbees/main/ClientProxy.java @@ -1,13 +1,15 @@ package magicbees.main; +import magicbees.client.render.RendererEffectJar; +import magicbees.client.render.RendererVisAuraProvider; +import magicbees.tileentity.TileEntityEffectJar; +import magicbees.tileentity.TileEntityVisAuraProvider; +import net.minecraft.item.Item; +import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import magicbees.client.render.EffectJarRenderer; -import magicbees.tileentity.TileEntityEffectJar; -import net.minecraft.item.Item; -import net.minecraftforge.client.MinecraftForgeClient; @SideOnly(Side.CLIENT) public class ClientProxy extends CommonProxy @@ -18,7 +20,11 @@ public class ClientProxy extends CommonProxy super.registerRenderers(); RenderIdEffectJar = RenderingRegistry.getNextAvailableRenderId(); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(Config.effectJar), EffectJarRenderer.instance); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEffectJar.class, EffectJarRenderer.instance); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(Config.effectJar), RendererEffectJar.instance); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEffectJar.class, RendererEffectJar.instance); + + RenderIdVisAuraProvider = RenderingRegistry.getNextAvailableRenderId(); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(Config.visAuraProvider), RendererVisAuraProvider.instance); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVisAuraProvider.class, RendererVisAuraProvider.instance); } } diff --git a/src/main/java/magicbees/main/CommonProxy.java b/src/main/java/magicbees/main/CommonProxy.java index 1d8581b..95bd6ab 100644 --- a/src/main/java/magicbees/main/CommonProxy.java +++ b/src/main/java/magicbees/main/CommonProxy.java @@ -30,6 +30,7 @@ public class CommonProxy public static final String GUI_PATH = TEXTURE_PATH + "gui/"; public static int RenderIdEffectJar; + public static int RenderIdVisAuraProvider; public void registerRenderers() { } diff --git a/src/main/java/magicbees/main/Config.java b/src/main/java/magicbees/main/Config.java index 105cf86..94b96eb 100644 --- a/src/main/java/magicbees/main/Config.java +++ b/src/main/java/magicbees/main/Config.java @@ -3,11 +3,12 @@ package magicbees.main; import java.io.File; import java.lang.reflect.Field; -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import magicbees.block.*; +import magicbees.block.BlockEffectJar; +import magicbees.block.BlockHive; +import magicbees.block.BlockMagicApiary; +import magicbees.block.BlockPlanks; +import magicbees.block.BlockVisAuraProvider; +import magicbees.block.BlockWoodSlab; import magicbees.block.types.HiveType; import magicbees.item.ItemCapsule; import magicbees.item.ItemComb; @@ -35,7 +36,8 @@ import magicbees.main.utils.VersionInfo; import magicbees.main.utils.compat.ThaumcraftHelper; import magicbees.storage.BackpackDefinition; import magicbees.tileentity.TileEntityEffectJar; -import magicbees.tileentity.TileEntityThaumicApiary; +import magicbees.tileentity.TileEntityMagicApiary; +import magicbees.tileentity.TileEntityVisAuraProvider; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; @@ -47,6 +49,10 @@ import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.apiculture.BeeManager; import forestry.api.storage.BackpackManager; import forestry.api.storage.EnumBackpackType; @@ -92,7 +98,8 @@ public class Config public static BlockWoodSlab slabWoodFull; public static BlockEffectJar effectJar; public static BlockHive hive; - public static BlockThaumicApiary thaumicApiary; + public static BlockMagicApiary magicApiary; + public static BlockVisAuraProvider visAuraProvider; public static ItemComb combs; public static ItemWax wax; @@ -129,6 +136,7 @@ public class Config //----- Forestry Blocks ------------------------------------ public static Block fHiveBlock; public static Block fAlvearyBlock; + public static Block fApicultureBlock; //----- Forestry Items ------------------------------------- public static Item fBeeComb; public static Item fHoneydew; @@ -144,6 +152,8 @@ public class Config public static Block tcLog; public static Block tcLeaf; public static Block tcWarded; + public static Block tcWooden; + public static Block tcMetal; //----- Thaumcraft Items ----------------------------------- public static Item tcFilledJar; public static Item tcMiscResource; @@ -240,6 +250,9 @@ public class Config { setupEffectJar(); setupHives(); + setupApiary(); + + setupThaumcraftBlocks(); } public void setupItems() @@ -258,8 +271,7 @@ public class Config setupThaumcraftItems(); setupFrames(); setupJellyBaby(); - voidCapsule = new ItemCapsule(CapsuleType.VOID, capsuleStackSizeMax); - setupThaumcraftTools(); + voidCapsule = new ItemCapsule(CapsuleType.VOID, capsuleStackSizeMax); moonDial = new ItemMoonDial(); setupNuggets(); @@ -388,6 +400,12 @@ public class Config GameRegistry.registerBlock(effectJar, "effectJar"); GameRegistry.registerTileEntity(TileEntityEffectJar.class, TileEntityEffectJar.tileEntityName); } + + private void setupApiary() { + magicApiary = new BlockMagicApiary(); + GameRegistry.registerBlock(magicApiary, "magicApiary"); + GameRegistry.registerTileEntity(TileEntityMagicApiary.class, TileEntityMagicApiary.tileEntityName); + } private void setupFrames() { hiveFrameMagic = new ItemMagicHiveFrame(HiveFrameType.MAGIC); @@ -488,36 +506,24 @@ public class Config } } } + + private void setupThaumcraftBlocks() { + if (ThaumcraftHelper.isActive()) { + visAuraProvider = new BlockVisAuraProvider(); + GameRegistry.registerBlock(visAuraProvider, "visAuraProvider"); + GameRegistry.registerTileEntity(TileEntityVisAuraProvider.class, "visAuraProvider"); + } + } private void setupThaumcraftItems() { if (ThaumcraftHelper.isActive()) { // Items - solidFlux = new ItemCrystalAspect(); - - // Blocks - thaumicApiary = new BlockThaumicApiary(); - GameRegistry.registerBlock(thaumicApiary, "thaumicApiary"); - GameRegistry.registerTileEntity(TileEntityThaumicApiary.class, TileEntityThaumicApiary.tileEntityName); - } - } - - private void setupThaumcraftTools() { - if (ThaumcraftHelper.isActive()) - { - try - { - thaumiumScoop = new ItemThaumiumScoop(); - GameRegistry.registerItem(thaumiumScoop, thaumiumScoop.getUnlocalizedName(), CommonProxy.DOMAIN); - - thaumiumGrafter = new ItemThaumiumGrafter(); - GameRegistry.registerItem(thaumiumGrafter, thaumiumGrafter.getUnlocalizedName(), CommonProxy.DOMAIN); - } - catch (Exception e) - { - LogHelper.warn("Couldn't register Thaumium tools!"); - LogHelper.debug(e); - } + thaumiumScoop = new ItemThaumiumScoop(); + GameRegistry.registerItem(thaumiumScoop, thaumiumScoop.getUnlocalizedName(), CommonProxy.DOMAIN); + + thaumiumGrafter = new ItemThaumiumGrafter(); + GameRegistry.registerItem(thaumiumGrafter, thaumiumGrafter.getUnlocalizedName(), CommonProxy.DOMAIN); } } diff --git a/src/main/java/magicbees/main/MagicBees.java b/src/main/java/magicbees/main/MagicBees.java index 69f0be6..1870e39 100644 --- a/src/main/java/magicbees/main/MagicBees.java +++ b/src/main/java/magicbees/main/MagicBees.java @@ -1,14 +1,5 @@ package magicbees.main; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; - import magicbees.bees.BeeManager; import magicbees.bees.TransmutationEffectController; import magicbees.client.gui.GUIHandler; @@ -17,6 +8,17 @@ import magicbees.main.utils.IMCManager; import magicbees.main.utils.LogHelper; import magicbees.main.utils.VersionInfo; import magicbees.main.utils.compat.ModHelper; +import magicbees.main.utils.net.NetworkEventHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; @Mod( modid = VersionInfo.ModName, @@ -34,10 +36,12 @@ public class MagicBees public GUIHandler guiHandler; private Config modConfig; + public final NetworkEventHandler netHandler = new NetworkEventHandler(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { + LogHelper.info("Preinit started"); this.modConfig = new Config(event.getSuggestedConfigurationFile()); FMLCommonHandler.instance().bus().register(modConfig); @@ -88,5 +92,14 @@ public class MagicBees { IMCManager.handle(event); } + + @Mod.EventHandler + public void handleMissingMapping(FMLMissingMappingsEvent event) { + for (MissingMapping mapping : event.get()) { + // TODO: ... maybe not this. + LogHelper.info(String.format("Missing mapping: %s - ignoring.", mapping.name)); + mapping.ignore(); + } + } } diff --git a/src/main/java/magicbees/main/utils/ChunkCoords.java b/src/main/java/magicbees/main/utils/ChunkCoords.java index 15277ba..d88d2b5 100644 --- a/src/main/java/magicbees/main/utils/ChunkCoords.java +++ b/src/main/java/magicbees/main/utils/ChunkCoords.java @@ -1,17 +1,93 @@ package magicbees.main.utils; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class ChunkCoords { - public int dimension; - public int xCoord; - public int zCoord; + public final int dimension; + public final int x; + public final int y; + public final int z; - public ChunkCoords(Chunk chunk) - { - this.dimension = chunk.worldObj.provider.dimensionId; - this.xCoord = chunk.xPosition; - this.zCoord = chunk.zPosition; + public ChunkCoords(TileEntity entity) { + this(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord); } + + public ChunkCoords(Entity entity) { + this(entity.worldObj, entity.chunkCoordX, entity.chunkCoordY, entity.chunkCoordZ); + } + + public ChunkCoords(World world, int xCoord, int yCoord, int zCoord) + { + this(world.provider.dimensionId, xCoord, yCoord, zCoord); + } + + public ChunkCoords(int dimId, int xCoord, int yCoord, int zCoord) + { + this.dimension = dimId; + this.x = xCoord; + this.y = yCoord; + this.z = zCoord; + } + + /** + * Adds chunk coords together & returns the result within the same dimension. + */ + public ChunkCoords add(ChunkCoords coords) { + return new ChunkCoords(coords.dimension, this.x + coords.x, this.y + coords.y, this.z + coords.z); + } + + /** + * Subtracts chunk coords (a.subtract(b) == a - b) & returns the result within the same dimension. + */ + public ChunkCoords subtract(ChunkCoords coords) { + return new ChunkCoords(coords.dimension, this.x - coords.x, this.y - coords.y, this.z - coords.z); + } + + /** + * Returns a new ChunkCoords in the specified dimension. + */ + public ChunkCoords inDimension(int dimId) { + return new ChunkCoords(dimId, x, y, z); + } + + /** + * Returns a new ChunkCoords in the specified world. + */ + public ChunkCoords inDimension(World world) { + return new ChunkCoords(world.provider.dimensionId, x, y, z); + } + + /** + * Writes obj to the given tag compound as a subtag. Writes nothing if obj is null. + */ + public static void writeToNBT(ChunkCoords obj, NBTTagCompound tagRoot) { + if (obj != null) { + NBTTagCompound coordsTag = new NBTTagCompound(); + coordsTag.setInteger("dim", obj.dimension); + coordsTag.setInteger("xPos", obj.x); + coordsTag.setInteger("yPos", obj.y); + coordsTag.setInteger("zPos", obj.z); + tagRoot.setTag("chunkCoords", coordsTag); + } + } + + /** + * Reads a ChunkCoords from an NBT tag. If no ChunkCoords subtag exists, returns null. + */ + public static ChunkCoords readFromNBT(NBTTagCompound tagRoot) { + if (tagRoot.hasKey("chunkCoords")) { + NBTTagCompound coordsTag = (NBTTagCompound)tagRoot.getTag("chunkCoords"); + int dim = coordsTag.getInteger("dim"); + int x = coordsTag.getInteger("xPos"); + int y = coordsTag.getInteger("yPos"); + int z = coordsTag.getInteger("zPos"); + return new ChunkCoords(dim, x, y, z); + } + return null; + } + } diff --git a/src/main/java/magicbees/main/utils/CraftingManager.java b/src/main/java/magicbees/main/utils/CraftingManager.java index 50e003a..07165d6 100644 --- a/src/main/java/magicbees/main/utils/CraftingManager.java +++ b/src/main/java/magicbees/main/utils/CraftingManager.java @@ -1,6 +1,5 @@ package magicbees.main.utils; -import cpw.mods.fml.common.registry.GameRegistry; import magicbees.item.ItemCapsule; import magicbees.item.types.CombType; import magicbees.item.types.DropType; @@ -23,6 +22,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.recipes.RecipeManagers; public class CraftingManager @@ -351,38 +351,16 @@ public class CraftingManager 'S', Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY) })); } - + + // TODO: Finalize recipe. + output = new ItemStack(Config.magicApiary); + GameRegistry.addShapelessRecipe(output, new Object[] { + Config.pollen.getStackForType(PollenType.UNUSUAL, 2), + new ItemStack(Config.fApicultureBlock, 1, ForestryHelper.ApicultureBlock.APIARY.ordinal()) + }); if (ThaumcraftHelper.isActive()) { - // Slabs - /*for (int i = 0; i < PlankType.values().length; ++i) - { - input = new ItemStack(Config.planksWood, 1, i); - output = new ItemStack(Config.slabWoodHalf, 6, i); - GameRegistry.addRecipe(output, new Object[] { - "PPP", - 'P', input - }); - }*/ - - // Essentia bottles - /*output = new ItemStack(Config.tcEssentiaBottle); - output.stackSize = 8; - GameRegistry.addRecipe(output, new Object[] { - " C ", "GPG", "PGP", - 'G', Config.wax, - 'C', Item.clay, - 'P', Block.thinGlass - }); - - output = new ItemStack(Config.tcEssentiaBottle); - output.stackSize = 4; - GameRegistry.addRecipe(output, new Object[] { - " W ", "W W", " W ", - 'W', Config.wax - });*/ - input = Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT); output = new ItemStack(Config.tcMiscResource, 1, ThaumcraftHelper.MiscResource.KNOWLEDGE_FRAGMENT.ordinal()); GameRegistry.addShapelessRecipe(output, new Object[] { @@ -400,20 +378,6 @@ public class CraftingManager 'C', Blocks.chest }); } - - // "bottling" Crystal aspects. - /*for (EnumTag tag : EnumTag.values()) - { - if (tag != EnumTag.UNKNOWN) - { - output = new ItemStack(Config.tcEssentiaBottle, 1, tag.id + 1); - GameRegistry.addRecipe(output, new Object[] { - "ccc", "cxc", "ccc", - 'c', new ItemStack(Config.solidFlux, 1, tag.id), - 'x', Config.tcEssentiaBottle - }); - } - }*/ } if (ArsMagicaHelper.isActive()) diff --git a/src/main/java/magicbees/main/utils/ItemStackUtils.java b/src/main/java/magicbees/main/utils/ItemStackUtils.java new file mode 100644 index 0000000..4cc9560 --- /dev/null +++ b/src/main/java/magicbees/main/utils/ItemStackUtils.java @@ -0,0 +1,103 @@ +package magicbees.main.utils; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public class ItemStackUtils { + + /** + * Attempts to add all items to the inventory, starting at startSlot and considering slotCount item slots. + * @return Number of items successfully added to the inventory. + */ + public static int tryAddItemStacksToInvenotry(IInventory inventory, ItemStack[] items, int startSlot, int slotCount) { + int itemsAdded = 0; + + for (ItemStack item : items) { + itemsAdded += addItemToInventory(inventory, item, startSlot, slotCount); + } + + return itemsAdded; + } + + /** + * Attempts to add all items to the inventory, starting at startSlot and considering slotCount item slots. + * @return true if and only if all items were successfully added to the inventory. + */ + public static boolean tryAddAllItemStacksToInventory(IInventory inventory, ItemStack[] items, int startSlot, int slotCount) { + int itemsToAdd = 0; + int itemsAdded = 0; + + for (ItemStack item : items) { + itemsToAdd += item.stackSize; + itemsAdded += addItemToInventory(inventory, item, startSlot, slotCount); + } + + return itemsToAdd == itemsAdded; + } + + /** + * Attempts to add an item to an inventory, starting at startSlot and considering slotCount item slots. + * @return number of items in the stack successfully added to the inventory. + */ + public static int addItemToInventory(IInventory inventory, ItemStack item, int startSlot, int slotCount) { + int itemsAdded = 0; + + itemsAdded = addToExistingSlot(inventory, item, startSlot, slotCount); + if (itemsAdded < item.stackSize) { + item.stackSize -= itemsAdded; + itemsAdded += addToEmptySlot(inventory, item, startSlot, slotCount); + } + + return itemsAdded; + } + + private static int addToExistingSlot(IInventory inventory, ItemStack item, int startSlot, int slotCount) { + int itemsAdded = 0; + + for (int slotIndex = startSlot; slotIndex < (startSlot + slotCount); ++slotIndex) { + ItemStack slotStack = inventory.getStackInSlot(slotIndex); + + // Skip empty slots. + if (slotStack != null && areItemsEqualNBT(item, slotStack)) { + int spaceAvailable = slotStack.getMaxStackSize() - slotStack.stackSize; + + if (spaceAvailable > item.stackSize) { + slotStack.stackSize += item.stackSize; + inventory.setInventorySlotContents(slotIndex, slotStack); + itemsAdded += item.stackSize; + item.stackSize = 0; + } + else if (spaceAvailable > 0) { + slotStack.stackSize = slotStack.getMaxStackSize(); + inventory.setInventorySlotContents(slotIndex, slotStack); + itemsAdded += spaceAvailable; + item.stackSize -= spaceAvailable; + } + } + + // Don't add beyond what we have. + if (item.stackSize == 0) { + break; + } + } + + return itemsAdded; + } + + private static int addToEmptySlot(IInventory inventory, ItemStack item, int startSlot, int slotCount) { + for (int slotIndex = startSlot; slotIndex < (startSlot + slotCount); ++slotIndex) { + ItemStack slotStack = inventory.getStackInSlot(slotIndex); + + if (slotStack == null) { + inventory.setInventorySlotContents(slotIndex, item); + return item.stackSize; + } + } + + return 0; + } + + public static boolean areItemsEqualNBT(ItemStack item, ItemStack otherItem) { + return item.isItemEqual(otherItem) && ItemStack.areItemStackTagsEqual(item, otherItem); + } +} diff --git a/src/main/java/magicbees/main/utils/compat/ForestryHelper.java b/src/main/java/magicbees/main/utils/compat/ForestryHelper.java index 47c1ea3..742c17f 100644 --- a/src/main/java/magicbees/main/utils/compat/ForestryHelper.java +++ b/src/main/java/magicbees/main/utils/compat/ForestryHelper.java @@ -9,11 +9,12 @@ import magicbees.main.Config; import magicbees.main.utils.BlockInterface; import magicbees.main.utils.ItemInterface; import magicbees.main.utils.VersionInfo; - import forestry.api.apiculture.hives.HiveManager; import forestry.api.apiculture.hives.IHiveRegistry; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; public class ForestryHelper @@ -93,6 +94,11 @@ public class ForestryHelper APATITE, LAPIS,; } + + public enum ApicultureBlock { + APIARY, + ; + } public static final String Name = "Forestry"; @@ -138,6 +144,7 @@ public class ForestryHelper Class c = Class.forName("forestry.core.config.ForestryBlock"); Config.fAlvearyBlock = BlockInterface.getBlock("alveary"); Config.fHiveBlock = BlockInterface.getBlock("beehives"); + Config.fApicultureBlock = BlockInterface.getBlock("apiculture"); } catch (Exception e) { @@ -168,4 +175,9 @@ public class ForestryHelper { return EnumHumidity.getFromValue(rawHumidity); } + + public static boolean isHumidityWithinTolerance(EnumHumidity humid, EnumHumidity beeHumidityBase, EnumTolerance value) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java b/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java index 86885ae..80a5761 100644 --- a/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java +++ b/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java @@ -31,10 +31,8 @@ import thaumcraft.api.research.ResearchPage; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; -public class ThaumcraftHelper -{ - public enum MiscResource - { +public class ThaumcraftHelper { + public enum MiscResource { ALUMENTUM, NITOR, THAUMIUM, @@ -45,92 +43,119 @@ public class ThaumcraftHelper ENCHANTED_FABRIC, FLUX_FILTER, KNOWLEDGE_FRAGMENT, - MIRRORED_GLASS,; + MIRRORED_GLASS, + ; } - public enum NuggetType - { + public enum NuggetType { IRON, COPPER, TIN, SILVER, LEAD, QUICKSILVER, - THAUMIUM, _7, _8, _9, _10, _11, _12, _13, _14, _15, + THAUMIUM, + _7, _8, _9, _10, _11, _12, _13, _14, _15, NATIVE_IRON, NATIVE_COPPER, NATIVE_TIN, NATIVE_SILVER, - NATIVE_LEAD, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, - NATIVE_GOLD,; + NATIVE_LEAD, + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, + NATIVE_GOLD, + ; } - public enum ShardType - { + public enum ShardType { AIR, FIRE, WATER, EARTH, ORDER, - CHAOS,; + CHAOS, + BALANCED, + ; } - public enum Entity - { + public enum MetalDeviceType { + CRUCIBLE, + ALEMBIC, + VIS_CHARGE_RELAY, + ADVANCED_ALCHEMICAL_CONSTRUCT, + _4, + ITEM_GRATE, + _6, + ARCANE_LAMP, + LAMP_OF_GROWTH, + ALCHEMICAL_CONSTRUCT, + THAUMATORIUM, + _11, + MNEMONIC_MATRIX, + LAMP_OF_FERTILITY, + VIS_RELAY, + ; + } + + public enum WoodenDeviceType { + BELLOWS, + EAR, + PRESSURE_PLATE, + BORE_BASE, + BORE, + PLANKS_GREATWOOD, + PLANKS_SILVERWOOD, + BANNER, + ; + } + + public enum Entity { BRAINY_ZOMBIE("entBrainyZombie", "EntityBrainyZombie"), GIANT_BRAINY_ZOMBIE("entGiantBrainyZombie", "EntityGiantBrainyZombie"), WISP("entWisp", "EntityWisp"), - FIREBAT("entFirebat", "EntityFireBat"),; + FIREBAT("entFirebat", "EntityFireBat"), + ; private static String packageName = "thaumcraft.common.entities.monster."; public String entityID; private String className; - private Entity(String id, String clazz) - { + private Entity(String id, String clazz) { this.entityID = id; this.className = clazz; } - public String getClassName() - { + public String getClassName() { return packageName + this.className; } } - public enum BlockPlant - { + public enum BlockPlant { GREATWOOD_SAPLING, SILVERWOOD_SAPLING, SHIMMERLEAF, CINDERPEARL, - PURIFYING_PLANT,; + PURIFYING_PLANT, + ; } - public enum TreeType - { + public enum TreeType { GREATWOOD, - SILVERWOOD,; + SILVERWOOD, + ; } - public static final String Name = "Thaumcraft"; private static boolean isThaumcraftPresent = false; - public static boolean isActive() - { + public static boolean isActive() { return isThaumcraftPresent; } - public static void preInit() - { - if (Loader.isModLoaded(Name) && Config.thaumcraftActive) - { + public static void preInit() { + if (Loader.isModLoaded(Name) && Config.thaumcraftActive) { isThaumcraftPresent = true; - } - else - { + } else { // Switch off TC-dependant items. ResourceType.LORE_FRAGMENT.setHidden(); ResourceType.TC_DUST_AIR.setHidden(); @@ -142,23 +167,22 @@ public class ThaumcraftHelper } } - public static void init() - { - //if (isActive()) { } + public static void init() { + // if (isActive()) { } } - public static void postInit() - { - if (isActive()) - { + public static void postInit() { + if (isActive()) { // Apparently the Game Registry isn't populated until now. ): getBlocks(); getItems(); - aspectTime = new Aspect("tempus", 0xB68CFF, new Aspect[] { Aspect.VOID, Aspect.ORDER }, - new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.TEXTURE + "aspects/tempus.png"), 1); + aspectTime = new Aspect("tempus", 0xB68CFF, new Aspect[] { + Aspect.VOID, Aspect.ORDER }, new ResourceLocation( + CommonProxy.DOMAIN, CommonProxy.TEXTURE + + "aspects/tempus.png"), 1); - //addItemsToBackpack(); + // addItemsToBackpack(); setupItemAspects(); setupCrafting(); setupResearch(); @@ -167,159 +191,6 @@ public class ThaumcraftHelper private static Object aspectTime; - private static void getBlocks() - { - Config.tcPlant = BlockInterface.getBlock(Name, "blockCustomPlant"); - Config.tcCandle = BlockInterface.getBlock(Name, "blockCandle"); - Config.tcCrystal = BlockInterface.getBlock(Name, "blockCrystal"); - Config.tcMarker = BlockInterface.getBlock(Name, "blockMarker"); - Config.tcJar = BlockInterface.getBlock(Name, "blockJar"); - Config.tcLog = BlockInterface.getBlock(Name, "blockMagicalLog"); - Config.tcLeaf = BlockInterface.getBlock(Name, "blockMagicalLeaves"); - Config.tcWarded = BlockInterface.getBlock(Name, "blockWarded"); - } - - private static void getItems() - { - Config.tcFilledJar = ItemInterface.getItem(Name, "BlockJarFilledItem"); - Config.tcMiscResource = ItemInterface.getItem(Name, "ItemResource"); - //Config.tcEssentiaBottle = ItemInterface.getItem(Name, "BlockJarFilledItem"); - Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); - Config.tcGolem = ItemInterface.getItem(Name, "ItemGolemPlacer"); - //Config.tcWispEssence = ItemApi.getItem("itemWispEssence", 0).getItem(); - Config.tcNuggets = ItemInterface.getItem(Name, "ItemNugget"); - Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); - Config.tcNuggetChicken = ItemInterface.getItem(Name, "ItemNuggetChicken"); - Config.tcNuggetBeef = ItemInterface.getItem(Name, "ItemNuggetBeef"); - Config.tcNuggetPork = ItemInterface.getItem(Name, "ItemNuggetPork"); - } - - private static void addItemsToBackpack() - { -// if (Config.addThaumcraftItemsToBackpacks) -// { -// // Add all shards and Thaumium to miner's backpack -// String ids = Config.tcShard.itemID + ":" + -1 + ";" -// + Config.tcMiscResource.itemID + ":" + ThaumcraftHelper.MiscResource.THAUMIUM.ordinal(); -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "miner@" + ids); -// -// // All resources go into Thaumaturge's backpack -// ids = Config.tcMiscResource.itemID + ":" + -1 + ";" -// + Config.tcShard.itemID + ":" + -1 + ";" -// + Config.tcFilledJar.itemID + ":" + -1 + ";" -// + Config.tcCrystal.blockID + ":" + -1 + ";" -// + Config.tcJar.blockID + ":" + -1 + ";" -// + Config.tcGolem.itemID + ":" + -1 + ";"; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "thaumaturge@" + ids); -// -// // Add some plants & saplings to Forester's -// ids = Config.tcPlant.blockID + ":" + "-1" + ";" -// + Config.tcLeaf.blockID + ":" + -1 + ";" -// + Config.tcLog.blockID + ":" + "-1"; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "forester@" + ids); -// -// // Add Wisp & brains to Hunter's -// ids = /*Config.tcWispEssence.itemID + ":" + -1 + ";" -// +*/ Config.tcMiscResource.itemID + ":" + ThaumcraftHelper.MiscResource.ZOMBIE_BRAIN.ordinal(); -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "hunter@" + ids); -// -// // Add Marker, warded stone, candle to builder -// ids = Config.tcCandle.blockID + ":" + -1 + ";" -// + Config.tcMarker.blockID + ":" + -1 + ";" -// + Config.tcWarded.blockID + ":" + -1; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "builder@" + ids); -// } - } - - private static void setupCrafting() - { - ItemStack input, output; - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_AIR); - output = new ItemStack(Config.tcShard, 1, ShardType.AIR.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_WATER); - output = new ItemStack(Config.tcShard, 1, ShardType.WATER.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_FIRE); - output = new ItemStack(Config.tcShard, 1, ShardType.FIRE.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_EARTH); - output = new ItemStack(Config.tcShard, 1, ShardType.EARTH.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_ORDER); - output = new ItemStack(Config.tcShard, 1, ShardType.ORDER.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_CHAOS); - output = new ItemStack(Config.tcShard, 1, ShardType.CHAOS.ordinal()); - GameRegistry.addShapelessRecipe(output, input, input, input, input); - - thaumScoop = ThaumcraftApi.addArcaneCraftingRecipe("MB_Scoop", new ItemStack(Config.thaumiumScoop), - new AspectList().add(Aspect.ORDER, 2), new Object[] { - "sWs", "sTs", " T ", - 's', Items.stick, - 'W', Blocks.wool, - 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) - }); - - thaumGrafter = ThaumcraftApi.addArcaneCraftingRecipe("MB_Grafter", new ItemStack(Config.thaumiumGrafter), - new AspectList().add(Aspect.ORDER, 5), new Object[] { - " T", " s ", "s ", - 's', Items.stick, - 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) - }); - - frameMagic = ThaumcraftApi.addArcaneCraftingRecipe("MB_FrameMagic", new ItemStack(Config.hiveFrameMagic), - new AspectList().add(Aspect.ORDER, 5).add(Aspect.AIR, 2).add(Aspect.EARTH, 2), new Object[] { - "sss", "sCs", "sss", - 's', Items.stick, - 'C', new ItemStack(Config.tcMiscResource, 1, MiscResource.ENCHANTED_FABRIC.ordinal()) - }); - - essenceLife = ThaumcraftApi.addCrucibleRecipe("MB_EssenceLife", Config.miscResources.getStackForType(ResourceType.ESSENCE_FALSE_LIFE), - new ItemStack(Blocks.red_flower), new AspectList().add(Aspect.EXCHANGE, 4).add(Aspect.PLANT, 4)); - - essenceDeath = ThaumcraftApi.addCrucibleRecipe("MB_EssenceDeath", Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE), - new ItemStack(Items.rotten_flesh), new AspectList().add(Aspect.DEATH, 4).add(Aspect.ENTROPY, 4)); - - essenceArmor = ThaumcraftApi.addCrucibleRecipe("MB_EssenceArmor", Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY), - new ItemStack(Items.leather), new AspectList().add(Aspect.ARMOR, 4).add(Aspect.MAGIC, 2)); - - output = Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE); - essenceUnstableA = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable", output, - Config.propolis.getStackForType(PropolisType.UNSTABLE), new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.EXCHANGE, 1)); - - essenceUnstableB = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable", output, - new ItemStack(Blocks.netherrack), new AspectList().add(Aspect.ENTROPY, 8).add(Aspect.EXCHANGE, 5)); - - essenceTime = ThaumcraftApi.addCrucibleRecipe("MB_EssenceTime", Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME), - new ItemStack(Items.clock), new AspectList().add(Aspect.ORDER, 10).add(Aspect.VOID, - 10).add(Aspect.TRAP, 4)); - - input = new ItemStack(Items.ender_pearl); - singularityA = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, 3), - 5, new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20), - new ItemStack(Blocks.gold_block), - new ItemStack[] { input, input }); - - ItemStack in2 = new ItemStack(Items.diamond); - singularityB = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, 3), - 6, new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20).add(Aspect.VOID, 15), - Config.propolis.getStackForType(PropolisType.UNSTABLE), - new ItemStack[] { input, input, in2 }); - - essenceOblivion = ThaumcraftApi.addShapelessArcaneCraftingRecipe("MB_EssenceOblivion", Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION), - new AspectList().add(Aspect.ENTROPY, 25).add(Aspect.AIR, 40).add(Aspect.ORDER, 15), new Object[] { - Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY), - Blocks.dragon_egg, - }); - } - private static Object frameMagic; private static Object thaumScoop; private static Object thaumGrafter; @@ -332,58 +203,203 @@ public class ThaumcraftHelper private static Object essenceUnstableB; private static Object essenceTime; private static Object essenceOblivion; + private static Object visAuraProvider; - private static void setupResearch() - { + private static void getBlocks() { + Config.tcPlant = BlockInterface.getBlock(Name, "blockCustomPlant"); + Config.tcCandle = BlockInterface.getBlock(Name, "blockCandle"); + Config.tcCrystal = BlockInterface.getBlock(Name, "blockCrystal"); + Config.tcMarker = BlockInterface.getBlock(Name, "blockMarker"); + Config.tcJar = BlockInterface.getBlock(Name, "blockJar"); + Config.tcLog = BlockInterface.getBlock(Name, "blockMagicalLog"); + Config.tcLeaf = BlockInterface.getBlock(Name, "blockMagicalLeaves"); + Config.tcWarded = BlockInterface.getBlock(Name, "blockWarded"); + Config.tcWooden = BlockInterface.getBlock(Name, "blockWoodenDevice"); + Config.tcMetal = BlockInterface.getBlock(Name, "blockMetalDevice"); + } + + private static void getItems() { + Config.tcFilledJar = ItemInterface.getItem(Name, "BlockJarFilledItem"); + Config.tcMiscResource = ItemInterface.getItem(Name, "ItemResource"); + // Config.tcEssentiaBottle = ItemInterface.getItem(Name, + // "BlockJarFilledItem"); + Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); + Config.tcGolem = ItemInterface.getItem(Name, "ItemGolemPlacer"); + // Config.tcWispEssence = ItemApi.getItem("itemWispEssence", + // 0).getItem(); + Config.tcNuggets = ItemInterface.getItem(Name, "ItemNugget"); + Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); + Config.tcNuggetChicken = ItemInterface.getItem(Name, + "ItemNuggetChicken"); + Config.tcNuggetBeef = ItemInterface.getItem(Name, "ItemNuggetBeef"); + Config.tcNuggetPork = ItemInterface.getItem(Name, "ItemNuggetPork"); + } + + private static void setupCrafting() { + ItemStack input, output; + + input = Config.miscResources.getStackForType(ResourceType.TC_DUST_AIR); + output = new ItemStack(Config.tcShard, 1, ShardType.AIR.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_WATER); + output = new ItemStack(Config.tcShard, 1, ShardType.WATER.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + input = Config.miscResources.getStackForType(ResourceType.TC_DUST_FIRE); + output = new ItemStack(Config.tcShard, 1, ShardType.FIRE.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_EARTH); + output = new ItemStack(Config.tcShard, 1, ShardType.EARTH.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_ORDER); + output = new ItemStack(Config.tcShard, 1, ShardType.ORDER.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_CHAOS); + output = new ItemStack(Config.tcShard, 1, ShardType.CHAOS.ordinal()); + GameRegistry.addShapelessRecipe(output, input, input, input, input); + + thaumScoop = ThaumcraftApi.addArcaneCraftingRecipe("MB_Scoop", new ItemStack(Config.thaumiumScoop), + new AspectList().add(Aspect.ORDER, 2), new Object[] { + "sWs", "sTs", " T ", + 's', Items.stick, + 'W', Blocks.wool, + 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) }); + + thaumGrafter = ThaumcraftApi.addArcaneCraftingRecipe("MB_Grafter", + new ItemStack(Config.thaumiumGrafter), + new AspectList().add(Aspect.ORDER, 5), new Object[] { + " T", " s ", "s ", + 's', Items.stick, + 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) }); + + frameMagic = ThaumcraftApi.addArcaneCraftingRecipe("MB_FrameMagic", new ItemStack(Config.hiveFrameMagic), + new AspectList().add(Aspect.ORDER, 5).add(Aspect.AIR, 2).add(Aspect.EARTH, 2), new Object[] { + "sss", "sCs", "sss", + 's', Items.stick, + 'C', new ItemStack(Config.tcMiscResource, 1, MiscResource.ENCHANTED_FABRIC.ordinal()) }); + + visAuraProvider = ThaumcraftApi.addArcaneCraftingRecipe("MB_VisAuraProvider", new ItemStack(Config.visAuraProvider), + new AspectList().add(Aspect.ORDER, 60).add(Aspect.AIR, 60).add(Aspect.ENTROPY, 60).add(Aspect.WATER, 60), + new Object[] { + "ngn", "gvg", "npn", + 'n', Items.gold_nugget, + 'g', new ItemStack(Config.tcWooden, 1, ThaumcraftHelper.WoodenDeviceType.PLANKS_GREATWOOD.ordinal()), + 'v', new ItemStack(Config.tcMetal, 1, ThaumcraftHelper.MetalDeviceType.VIS_RELAY.ordinal()), + 'p', Config.pollen.getStackForType(PollenType.UNUSUAL)}); + + essenceLife = ThaumcraftApi.addCrucibleRecipe("MB_EssenceLife", Config.miscResources.getStackForType(ResourceType.ESSENCE_FALSE_LIFE), + new ItemStack(Blocks.red_flower), + new AspectList().add(Aspect.EXCHANGE, 4).add(Aspect.PLANT, 4)); + + essenceDeath = ThaumcraftApi.addCrucibleRecipe("MB_EssenceDeath", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE), + new ItemStack(Items.rotten_flesh), + new AspectList().add(Aspect.DEATH, 4).add(Aspect.ENTROPY, 4)); + + essenceArmor = ThaumcraftApi.addCrucibleRecipe("MB_EssenceArmor", Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY), + new ItemStack(Items.leather), + new AspectList().add(Aspect.ARMOR, 4).add(Aspect.MAGIC, 2)); + + output = Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE); + essenceUnstableA = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable", output, + Config.propolis.getStackForType(PropolisType.UNSTABLE), + new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.EXCHANGE, 1)); + + essenceUnstableB = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable",output, + new ItemStack(Blocks.netherrack), + new AspectList().add(Aspect.ENTROPY, 8).add(Aspect.EXCHANGE, 5)); + + essenceTime = ThaumcraftApi.addCrucibleRecipe("MB_EssenceTime", Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME), + new ItemStack(Items.clock), + new AspectList().add(Aspect.ORDER, 10).add(Aspect.VOID, 10).add(Aspect.TRAP, 4)); + + input = new ItemStack(Items.ender_pearl); + singularityA = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", + Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY,3), + 5, + new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20), + new ItemStack(Blocks.gold_block), new ItemStack[] { input, + input }); + + ItemStack in2 = new ItemStack(Items.diamond); + singularityB = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", + Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, 3), + 6, + new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20).add(Aspect.VOID, 15), + Config.propolis.getStackForType(PropolisType.UNSTABLE), + new ItemStack[] { input, input, in2 }); + + essenceOblivion = ThaumcraftApi.addShapelessArcaneCraftingRecipe("MB_EssenceOblivion", + Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION), + new AspectList().add(Aspect.ENTROPY, 25).add(Aspect.AIR, 40).add(Aspect.ORDER, 15), + new Object[] { + Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY), + Blocks.dragon_egg, }); + } + + private static void setupResearch() { ArrayList list; ItemStack input; IRecipe recipe; String category = "MAGICBEES"; - ResearchCategories.registerCategory(category, new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.ITEM_TEXTURE + "beeInfusion.png"), + ResearchCategories.registerCategory(category, new ResourceLocation( + CommonProxy.DOMAIN, CommonProxy.ITEM_TEXTURE + "beeInfusion.png"), new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png")); - ResearchItem rootNodeR = new ResearchItem("MB_Root", category, new AspectList(), + ResearchItem rootNodeR = new ResearchItem("MB_Root", category, + new AspectList(), 0, 0, 0, Config.miscResources.getStackForType(ResourceType.RESEARCH_BEEINFUSION)) - .setRound().setStub().setAutoUnlock() - .setPages(getResearchPage("MB_Root.1"), getResearchPage("MB_Root.2")) - .registerResearchItem(); + .setRound() + .setStub() + .setAutoUnlock() + .setPages(getResearchPage("MB_Root.1"), getResearchPage("MB_Root.2")).registerResearchItem(); list = new ArrayList(4); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); - recipe = new ShapelessRecipes(new ItemStack(Config.tcMiscResource, 1, MiscResource.KNOWLEDGE_FRAGMENT.ordinal()), list); + recipe = new ShapelessRecipes(new ItemStack(Config.tcMiscResource, 1, + MiscResource.KNOWLEDGE_FRAGMENT.ordinal()), list); - ResearchItem researchFragment = new ResearchItem("MB_LoreFragment", category, new AspectList(), - 0, -3, 0, + ResearchItem researchFragment = new ResearchItem("MB_LoreFragment", category, + new AspectList(), + 0, -3, 1, Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)) - .setPages(getResearchPage("MB_LoreFragment.1"), new ResearchPage(recipe)) - .setParents("MB_Root") - .setStub().setAutoUnlock().setRound() - .registerResearchItem(); + .setPages(getResearchPage("MB_LoreFragment.1"), new ResearchPage(recipe)).setParents("MB_Root") + .setStub().setAutoUnlock().setRound().registerResearchItem(); - ResearchItem thaumiumScoopR = new ResearchItem("MB_Scoop", category, new AspectList().add(Aspect.TOOL, 1).add(Aspect.MAGIC, 1).add(Aspect.AIR, 1), + ResearchItem thaumiumScoopR = new ResearchItem("MB_Scoop", category, + new AspectList().add(Aspect.TOOL, 1).add(Aspect.MAGIC, 1).add(Aspect.AIR, 1), -2, -3, 1, new ItemStack(Config.thaumiumScoop)) - .setPages(getResearchPage("MB_Scoop.1"), new ResearchPage((IArcaneRecipe)thaumScoop)) - .setParentsHidden("THAUMIUM") - .registerResearchItem(); + .setPages(getResearchPage("MB_Scoop.1"), new ResearchPage((IArcaneRecipe) thaumScoop)) + .setParentsHidden("THAUMIUM").registerResearchItem(); - ResearchItem thaumiumGrafterR = new ResearchItem("MB_Grafter", category, new AspectList().add(Aspect.TOOL, 2).add(Aspect.TREE, 1).add(Aspect.GREED, 1), - -2, -1, 4, + ResearchItem thaumiumGrafterR = new ResearchItem("MB_Grafter", category, + new AspectList().add(Aspect.TOOL, 1).add(Aspect.TREE, 1).add(Aspect.GREED, 1), + -2, -1, 2, new ItemStack(Config.thaumiumGrafter)) - .setPages(getResearchPage("MB_Grafter.1"), new ResearchPage((IArcaneRecipe)thaumGrafter)) - .setParents("MB_Scoop") - .registerResearchItem(); + .setPages(getResearchPage("MB_Grafter.1"), new ResearchPage((IArcaneRecipe) thaumGrafter)) + .setParents("MB_Scoop").registerResearchItem(); - ResearchItem frameMagicR = new ResearchItem("MB_FrameMagic", category, new AspectList().add(Aspect.TOOL, 2).add(Aspect.ARMOR, 1), - -2, 1, 2, + ResearchItem frameMagicR = new ResearchItem("MB_FrameMagic", category, + new AspectList().add(Aspect.TOOL, 1).add(Aspect.ARMOR, 1), + -2, 1, 1, new ItemStack(Config.hiveFrameMagic)) - .setPages(getResearchPage("MB_FrameMagic"), new ResearchPage((IArcaneRecipe)frameMagic)) - .registerResearchItem(); + .setPages(getResearchPage("MB_FrameMagic"), new ResearchPage((IArcaneRecipe) frameMagic)) + .registerResearchItem(); input = new ItemStack(Config.hiveFrameMagic); list = new ArrayList(2); @@ -391,125 +407,138 @@ public class ThaumcraftHelper list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameGentle), list); - ResearchItem essenceFalseLifeR = new ResearchItem("MB_EssenceLife", category, new AspectList().add(Aspect.LIFE, 2).add(Aspect.MAGIC, 1), - 2, -1, 2, + ResearchItem essenceFalseLifeR = new ResearchItem("MB_EssenceLife", category, + new AspectList().add(Aspect.LIFE, 1).add(Aspect.MAGIC, 1), + 2, -1, 1, Config.miscResources.getStackForType(ResourceType.ESSENCE_FALSE_LIFE)) - .setPages(getResearchPage("MB_EssenceLife.1"), new ResearchPage((CrucibleRecipe)essenceLife), new ResearchPage(recipe)) - .setParentsHidden("CRUCIBLE") - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceLife.1"), + new ResearchPage((CrucibleRecipe) essenceLife), + new ResearchPage(recipe)).setParentsHidden("CRUCIBLE") + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameResilient), list); - ResearchItem essenceDurabilityR = new ResearchItem("MB_EssenceArmor", category, new AspectList().add(Aspect.ARMOR, 1).add(Aspect.MAGIC, 1), - 5, 0, 3, + ResearchItem essenceDurabilityR = new ResearchItem("MB_EssenceArmor", category, + new AspectList().add(Aspect.ARMOR, 1).add(Aspect.MAGIC, 1), + 5, 0, 2, Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY)) - .setPages(getResearchPage("MB_EssenceArmor.1"), new ResearchPage((CrucibleRecipe)essenceArmor), new ResearchPage(recipe)) - .setParents("MB_EssenceLife") - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceArmor.1"), + new ResearchPage((CrucibleRecipe) essenceArmor), + new ResearchPage(recipe)).setParents("MB_EssenceLife") + .registerResearchItem(); list = new ArrayList(2); - list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)); + list.add(Config.miscResources .getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameMetabolic), list); - ResearchItem essenceUnstableR = new ResearchItem("MB_EssenceUnstable", category, new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.ORDER, 1), - 3, 1, 4, + ResearchItem essenceUnstableR = new ResearchItem( "MB_EssenceUnstable", category, + new AspectList().add(Aspect.ENTROPY, 1).add(Aspect.ORDER, 1), + 3, 1, 2, Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)) - .setPages(getResearchPage("MB_EssenceUnstable.1"), new ResearchPage((CrucibleRecipe)essenceUnstableA), - new ResearchPage((CrucibleRecipe)essenceUnstableB), new ResearchPage(recipe)) - .setParents("MB_EssenceLife") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceUnstable.1"), + new ResearchPage((CrucibleRecipe) essenceUnstableA), + new ResearchPage((CrucibleRecipe) essenceUnstableB), + new ResearchPage(recipe)) + .setParents("MB_EssenceLife") + .setConcealed() + .registerResearchItem(); list = new ArrayList(2); - list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)); + list.add(Config.miscResources .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameNecrotic), list); - ResearchItem essenceShallowGraveR = new ResearchItem("MB_EssenceDeath", category, new AspectList().add(Aspect.DEATH, 2).add(Aspect.MAGIC, 1), - 2, 3, 2, - Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)) - .setPages(getResearchPage("MB_EssenceDeath.1"), new ResearchPage((CrucibleRecipe)essenceDeath), new ResearchPage(recipe)) - .setParents("MB_EssenceUnstable") - .setConcealed() - .registerResearchItem(); + ResearchItem essenceShallowGraveR = new ResearchItem("MB_EssenceDeath", category, + new AspectList().add(Aspect.DEATH, 1).add(Aspect.MAGIC, 1), + 2, 3, 1, + Config.miscResources .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)) + .setPages(getResearchPage("MB_EssenceDeath.1"), + new ResearchPage((CrucibleRecipe) essenceDeath), + new ResearchPage(recipe)) + .setParents("MB_EssenceUnstable") + .setConcealed() + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameTemporal), list); - ResearchItem essenceTimeR = new ResearchItem("MB_EssenceTime", category, new AspectList().add((Aspect)aspectTime, 2).add(Aspect.MAGIC, 1), - 0, 2, 5, + ResearchItem essenceTimeR = new ResearchItem("MB_EssenceTime", category, + new AspectList().add((Aspect) aspectTime, 1).add(Aspect.MAGIC, 1), + 0, 2, 2, Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME)) - .setPages(getResearchPage("MB_EssenceTime.1"), new ResearchPage((CrucibleRecipe)essenceTime), new ResearchPage(recipe)) - .setParents("MB_EssenceUnstable") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceTime.1"), + new ResearchPage((CrucibleRecipe) essenceTime), + new ResearchPage(recipe)) + .setParents("MB_EssenceUnstable") + .setConcealed() + .registerResearchItem(); - ResearchItem singularityR = new ResearchItem("MB_DimensionalSingularity", category, new AspectList().add(Aspect.ELDRITCH, 2).add((Aspect)aspectTime, 1).add(Aspect.VOID, 1), - -1, 4, 5, + ResearchItem singularityR = new ResearchItem("MB_DimensionalSingularity", category, + new AspectList().add(Aspect.ELDRITCH, 1).add((Aspect) aspectTime, 1).add(Aspect.VOID, 1), + -1, 4, 3, Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY)) - .setPages(getResearchPage("MB_DimensionalSingularity.1"), new ResearchPage((InfusionRecipe)singularityA), new ResearchPage((InfusionRecipe)singularityB)) - .setParents("MB_FrameMagic", "MB_EssenceTime", "MB_EssenceDeath") - .setConcealed() - .setSpecial() - .registerResearchItem(); + .setPages(getResearchPage("MB_DimensionalSingularity.1"), + new ResearchPage((InfusionRecipe) singularityA), + new ResearchPage((InfusionRecipe) singularityB)) + .setParents("MB_FrameMagic", "MB_EssenceTime", "MB_EssenceDeath") + .setConcealed() + .setSpecial() + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION)); list.add(ItemInterface.getItemStack("frameProven")); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameOblivion), list); - ResearchItem essenceOblivionR = new ResearchItem("MB_EssenceOblivion", category, new AspectList().add(Aspect.VOID, 2).add(Aspect.HUNGER, 1).add((Aspect)aspectTime, 1), - -3, 3, 5, + ResearchItem essenceOblivionR = new ResearchItem("MB_EssenceOblivion", category, + new AspectList().add(Aspect.VOID, 1).add(Aspect.HUNGER, 1).add((Aspect) aspectTime, 1), + -3, 3, 3, Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION)) - .setPages(getResearchPage("MB_EssenceOblivion.1"), new ResearchPage((IArcaneRecipe)essenceOblivion), new ResearchPage(recipe)) - .setParents("MB_DimensionalSingularity") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceOblivion.1"), + new ResearchPage((IArcaneRecipe) essenceOblivion), + new ResearchPage(recipe)) + .setParents("MB_DimensionalSingularity").setConcealed() + .registerResearchItem(); + + ResearchItem visAuraProviderR = new ResearchItem("MB_VisAuraProvider", category, + new AspectList().add(Aspect.MAGIC, 1).add(Aspect.ENERGY, 1).add(Aspect.AURA, 1), + -5, 5, 3, + new ItemStack(Config.visAuraProvider)) + .setPages(getResearchPage("MB_VisAuraProvider.1"), + new ResearchPage((IArcaneRecipe) visAuraProvider)) + .setParentsHidden("NodeRelay") + .registerResearchItem(); } - private static ResearchPage getResearchPage(String ident) - { - // Helps get around all the stupid XML Doctype restrictions. - return new ResearchPage(LocalizationManager.getLocalizedString("tc.research_page." + ident) - .replaceAll("##lineBreak##", "
") - .replaceAll("##horizontalRule##", "") - .replaceAll("##img##", "") - .replaceAll("##/img##", "")); + private static ResearchPage getResearchPage(String ident) { + return new ResearchPage(LocalizationManager.getLocalizedString("tc.research_page." + ident)); } - private static void setupItemAspects() - { + private static void setupItemAspects() { ItemStack item; AspectList list; - ThaumcraftApi.registerObjectTag(new ItemStack(Items.clock), new AspectList(new ItemStack(Items.clock)).add( - (Aspect)aspectTime, 4)); - ThaumcraftApi.registerObjectTag(new ItemStack(Items.repeater), new AspectList(new ItemStack(Items.repeater)).add( - (Aspect)aspectTime, 2)); - + ThaumcraftApi.registerObjectTag(new ItemStack(Items.clock), new AspectList(new ItemStack(Items.clock)).add((Aspect) aspectTime, 4)); + ThaumcraftApi.registerObjectTag(new ItemStack(Items.repeater), new AspectList(new ItemStack(Items.repeater)).add((Aspect) aspectTime, 2)); list = new AspectList(new ItemStack(Blocks.log)); - for (int i = 1; i <= 8; i++) - { + for (int i = 1; i <= 8; i++) { item = ItemInterface.getItemStack("log" + i); - if (item != null) - { + if (item != null) { ThaumcraftApi.registerObjectTag(item, list); } } list = new AspectList(new ItemStack(Blocks.planks)); - for (int i = 1; i <= 2; i++) - { + for (int i = 1; i <= 2; i++) { item = ItemInterface.getItemStack("planks" + i); - if (item != null) - { + if (item != null) { ThaumcraftApi.registerObjectTag(item, list); } } @@ -543,18 +572,15 @@ public class ThaumcraftHelper item = ForestryBlock.saplingGE.getItemStack(); ThaumcraftApi.registerObjectTag(item, list); - list = new AspectList()/*.add(Aspect.SEED, 1)*/.add(Aspect.PLANT, 1); + list = new AspectList()/* .add(Aspect.SEED, 1) */.add(Aspect.PLANT, 1); item = ForestryItem.pollenFertile.getItemStack(); ThaumcraftApi.registerObjectTag(item, list); list = new AspectList().add(Aspect.CRYSTAL, 1).add(Aspect.EARTH, 2); item = ForestryItem.apatite.getItemStack(); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.BlockResource.APATITE.ordinal()), - list.copy()/*.add(Aspect.STONE, 2)*/); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1,ForestryHelper.BlockResource.APATITE.ordinal()), list.copy()); item = ForestryItem.apatite.getItemStack(); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, item.getItemDamage()), - list.copy().add(Aspect.CRYSTAL, 2)); - + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, item.getItemDamage()), list.copy().add(Aspect.CRYSTAL, 2)); list = new AspectList().add(Aspect.MOTION, 2).add(Aspect.FLIGHT, 1); item = ItemInterface.getItemStack("beeDroneGE"); @@ -585,47 +611,30 @@ public class ThaumcraftHelper list = new AspectList().add(Aspect.SLIME, 1); item = ItemInterface.getItemStack("propolis"); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.NORMAL.ordinal()), - list); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.SILKY.ordinal()), - list.copy().add(Aspect.SLIME, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.PULSATING.ordinal()), - list.copy().add(Aspect.ELDRITCH, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.UNSTABLE.ordinal()), - list.copy().add(Aspect.ENTROPY, 1).add(Aspect.EXCHANGE, 1)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.AIR.ordinal()), - list.copy().add(Aspect.AIR, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.WATER.ordinal()), - list.copy().add(Aspect.WATER, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.FIRE.ordinal()), - list.copy().add(Aspect.FIRE, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.EARTH.ordinal()), - list.copy().add(Aspect.EARTH, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.ORDER.ordinal()), - list.copy().add(Aspect.ORDER, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.CHAOS.ordinal()), - list.copy().add(Aspect.ENTROPY, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.NORMAL.ordinal()), list); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.SILKY.ordinal()), list.copy().add(Aspect.SLIME, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.PULSATING.ordinal()), list.copy().add(Aspect.ELDRITCH, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.UNSTABLE.ordinal()), list.copy().add(Aspect.ENTROPY, 1).add(Aspect.EXCHANGE, 1)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.AIR.ordinal()), list.copy().add(Aspect.AIR, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.WATER.ordinal()), list.copy().add(Aspect.WATER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.FIRE.ordinal()), list.copy().add(Aspect.FIRE, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.EARTH.ordinal()), list.copy().add(Aspect.EARTH, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.ORDER.ordinal()), list.copy().add(Aspect.ORDER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.CHAOS.ordinal()), list.copy().add(Aspect.ENTROPY, 2)); list = new AspectList().add(Aspect.PLANT, 2); item = ItemInterface.getItemStack("pollen"); ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.NORMAL.ordinal()), list); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.CRYSTALLINE.ordinal()), - list.copy()/*.add(Aspect.ICE, 2)*/); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.UNUSUAL.ordinal()), - list.copy().add(Aspect.MAGIC, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.PHASED.ordinal()), - list.copy().add((Aspect)aspectTime, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.CRYSTALLINE.ordinal()), list.copy()); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.UNUSUAL.ordinal()), list.copy().add(Aspect.MAGIC, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.PHASED.ordinal()), list.copy().add((Aspect) aspectTime, 2)); list = new AspectList().add(Aspect.ORDER, 1); item = ItemInterface.getItemStack("beeswax"); - ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, list.copy().add(Aspect.ORDER, - 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.MAGIC.ordinal()), - list.copy().add(Aspect.MAGIC, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.SOUL.ordinal()), - list.copy().add(Aspect.SOUL, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.AMNESIC.ordinal()), - list.copy().add(Aspect.MIND, 2)); + ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, list.copy().add(Aspect.ORDER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.MAGIC.ordinal()), list.copy().add(Aspect.MAGIC, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.SOUL.ordinal()), list.copy().add(Aspect.SOUL, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.AMNESIC.ordinal()), list.copy().add(Aspect.MIND, 2)); list = new AspectList().add(Aspect.EXCHANGE, 2).add(Aspect.LIFE, 2); item = ItemInterface.getItemStack("honeyDrop"); @@ -653,7 +662,6 @@ public class ThaumcraftHelper ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.ARMOR, 6)); item = Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME); - ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.VOID, - 6).add((Aspect)aspectTime, 8)); + ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.VOID, 6).add((Aspect) aspectTime, 8)); } } diff --git a/src/main/java/magicbees/main/utils/error/InvalidEventTypeIndexException.java b/src/main/java/magicbees/main/utils/error/InvalidEventTypeIndexException.java new file mode 100644 index 0000000..4ae735b --- /dev/null +++ b/src/main/java/magicbees/main/utils/error/InvalidEventTypeIndexException.java @@ -0,0 +1,13 @@ +package magicbees.main.utils.error; + +public class InvalidEventTypeIndexException extends RuntimeException { + private static final long serialVersionUID = 8920019214439088440L; + + public InvalidEventTypeIndexException(String message) { + this(message, null); + } + + public InvalidEventTypeIndexException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/magicbees/main/utils/net/EventAuraChargeUpdate.java b/src/main/java/magicbees/main/utils/net/EventAuraChargeUpdate.java new file mode 100644 index 0000000..d472d33 --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/EventAuraChargeUpdate.java @@ -0,0 +1,69 @@ +package magicbees.main.utils.net; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.client.FMLClientHandler; + +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.LogHelper; +import magicbees.main.utils.net.NetworkEventHandler.EventType; +import magicbees.tileentity.AuraCharges; +import magicbees.tileentity.ITileEntityAuraCharged; + +public class EventAuraChargeUpdate extends EventCoords { + + private int flags; + + public EventAuraChargeUpdate(ChunkCoords position, AuraCharges auraCharges) { + super(EventType.AURA_CHARGE_UPDATE, position); + flags = auraCharges.writeToFlags(); + } + + public EventAuraChargeUpdate(DataInputStream byteStream) { + super(EventType.FLAGS_UPDATE, byteStream); + + this.readDataFromInputStream(byteStream); + } + + @Override + protected void writeDataToOutputStream(DataOutputStream byteStream) { + super.writeDataToOutputStream(byteStream); + + try { + byteStream.writeInt(flags); + } + catch (IOException e) { + LogHelper.error("Could not write EventAuraChargeUpdate data to stream."); + e.printStackTrace(); + } + } + + @Override + protected void readDataFromInputStream(DataInputStream byteStream) { + super.readDataFromInputStream(byteStream); + + try { + this.flags = byteStream.readInt(); + } + catch (IOException e) { + LogHelper.error("Could not read EventAuraChargeUpdate data from stream."); + e.printStackTrace(); + } + } + + @Override + public void process(EntityPlayerMP player) { + TileEntity tile = FMLClientHandler.instance().getClient().theWorld.getTileEntity(getCoords().x, getCoords().y, getCoords().z); + + if (tile != null && tile instanceof ITileEntityAuraCharged) { + AuraCharges auraCharges = ((ITileEntityAuraCharged) tile).getAuraCharges(); + auraCharges.readFromFlags(flags); + } + } + +} diff --git a/src/main/java/magicbees/main/utils/net/EventBase.java b/src/main/java/magicbees/main/utils/net/EventBase.java new file mode 100644 index 0000000..eb50836 --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/EventBase.java @@ -0,0 +1,119 @@ +package magicbees.main.utils.net; + +import forestry.core.proxy.Proxies; +import io.netty.buffer.Unpooled; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import magicbees.main.utils.LogHelper; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.common.registry.GameData; + +public class EventBase { + + private NetworkEventHandler.EventType eventType; + + public EventBase() { + this.eventType = NetworkEventHandler.EventType.UNKNOWN; + } + + public EventBase(NetworkEventHandler.EventType type) { + this.eventType = type; + } + + public FMLProxyPacket getPacket() { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + + try { + data.writeInt(eventType.ordinal()); + writeDataToOutputStream(data); + } + catch (IOException e) { + LogHelper.error("Could not write EventBase data."); + e.printStackTrace(); + } + + return new FMLProxyPacket(Unpooled.wrappedBuffer(bytes.toByteArray()), NetworkEventHandler.CHANNEL_NAME); + } + + public void process(EntityPlayerMP player) { + + } + + protected void writeDataToOutputStream(DataOutputStream data) { + return; + } + + protected void readDataFromInputStream(DataInputStream data) { + return; + } + + protected ItemStack readItemStackFromData(DataInputStream data) throws IOException { + ItemStack itemstack = null; + + String itemName = data.readUTF(); + + if (!itemName.isEmpty()) { + Item item = GameData.getItemRegistry().getRaw(itemName); + byte stackSize = data.readByte(); + short meta = data.readShort(); + itemstack = new ItemStack(item, stackSize, meta); + + if (item.isDamageable() || Proxies.common.needsTagCompoundSynched(item)) { + itemstack.stackTagCompound = this.readNBTTagCompound(data); + } + } + + return itemstack; + } + + protected void writeItemStackToData(ItemStack itemstack, DataOutputStream data) throws IOException { + if (itemstack == null) { + data.writeUTF(""); + } else { + data.writeUTF(GameData.getItemRegistry().getNameForObject(itemstack.getItem())); + data.writeByte(itemstack.stackSize); + data.writeShort(itemstack.getItemDamage()); + + if (itemstack.getItem().isDamageable() || Proxies.common.needsTagCompoundSynched(itemstack.getItem())) { + this.writeNBTTagCompound(itemstack.stackTagCompound, data); + } + } + } + + protected NBTTagCompound readNBTTagCompound(DataInputStream data) throws IOException { + + short length = data.readShort(); + + if (length < 0) { + return null; + } else { + byte[] compressed = new byte[length]; + data.readFully(compressed); + return CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed)); + } + + } + + protected void writeNBTTagCompound(NBTTagCompound nbttagcompound, DataOutputStream data) throws IOException { + + if (nbttagcompound == null) { + data.writeShort(-1); + } else { + byte[] compressed = CompressedStreamTools.compress(nbttagcompound); + data.writeShort((short) compressed.length); + data.write(compressed); + } + + } +} diff --git a/src/main/java/magicbees/main/utils/net/EventCoords.java b/src/main/java/magicbees/main/utils/net/EventCoords.java new file mode 100644 index 0000000..907e74b --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/EventCoords.java @@ -0,0 +1,60 @@ +package magicbees.main.utils.net; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.LogHelper; + +public class EventCoords extends EventBase { + + private ChunkCoords coords; + + public EventCoords(NetworkEventHandler.EventType type, ChunkCoords position) { + super(type); + this.coords = position; + } + + public EventCoords(NetworkEventHandler.EventType type, DataInputStream byteStream) { + super(type); + } + + public ChunkCoords getCoords() { + return this.coords; + } + + @Override + protected void writeDataToOutputStream(DataOutputStream byteStream) { + super.writeDataToOutputStream(byteStream); + + try { + byteStream.writeInt(coords.dimension); + byteStream.writeInt(coords.x); + byteStream.writeInt(coords.y); + byteStream.writeInt(coords.z); + } + catch (IOException e) { + LogHelper.error("Could not write EventCoords data to stream."); + e.printStackTrace(); + } + } + + @Override + protected void readDataFromInputStream(DataInputStream byteStream) { + super.readDataFromInputStream(byteStream); + + try { + int dim = byteStream.readInt(); + int x = byteStream.readInt(); + int y = byteStream.readInt(); + int z = byteStream.readInt(); + + this.coords = new ChunkCoords(dim, x, y, z); + } + catch (IOException e) { + LogHelper.error("Could not read EventCoords data from stream."); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/magicbees/main/utils/net/EventFlagsUpdate.java b/src/main/java/magicbees/main/utils/net/EventFlagsUpdate.java new file mode 100644 index 0000000..e5042c9 --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/EventFlagsUpdate.java @@ -0,0 +1,77 @@ +package magicbees.main.utils.net; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import cpw.mods.fml.client.FMLClientHandler; +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.LogHelper; +import magicbees.main.utils.net.NetworkEventHandler.EventType; +import magicbees.tileentity.ITileEntityFlags; + +public class EventFlagsUpdate extends EventCoords { + + private int[] flags; + + public EventFlagsUpdate(ChunkCoords position, int[] flagValues) { + super(EventType.FLAGS_UPDATE, position); + flags = flagValues; + } + + public EventFlagsUpdate(DataInputStream byteStream) { + super(EventType.FLAGS_UPDATE, byteStream); + + this.readDataFromInputStream(byteStream); + } + + public int[] getFlags() { + return flags; + } + + @Override + protected void writeDataToOutputStream(DataOutputStream byteStream) { + super.writeDataToOutputStream(byteStream); + + try { + byteStream.writeByte(flags.length); + for (int index = 0; index < flags.length; ++index) { + byteStream.writeInt(flags[index]); + } + } + catch (IOException e) { + LogHelper.error("Could not write EventFlagsUpdate data to stream."); + e.printStackTrace(); + } + } + + @Override + protected void readDataFromInputStream(DataInputStream byteStream) { + super.readDataFromInputStream(byteStream); + + try { + byte length = byteStream.readByte(); + + this.flags = new int[length]; + for (int index = 0; index < length; ++index) { + flags[index] = byteStream.readInt(); + } + } + catch (IOException e) { + LogHelper.error("Could not read EventFlagsUpdate data from stream."); + e.printStackTrace(); + } + } + + @Override + public void process(EntityPlayerMP player) { + TileEntity tile = FMLClientHandler.instance().getClient().theWorld.getTileEntity(getCoords().x, getCoords().y, getCoords().z); + + if (tile != null && tile instanceof ITileEntityFlags) { + ((ITileEntityFlags) tile).setFlags(this.flags); + } + } + +} diff --git a/src/main/java/magicbees/main/utils/net/EventInventoryUpdate.java b/src/main/java/magicbees/main/utils/net/EventInventoryUpdate.java new file mode 100644 index 0000000..c813783 --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/EventInventoryUpdate.java @@ -0,0 +1,67 @@ +package magicbees.main.utils.net; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import cpw.mods.fml.client.FMLClientHandler; +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.LogHelper; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class EventInventoryUpdate extends EventCoords { + + private int slotIndex; + private ItemStack itemStack; + + public EventInventoryUpdate(ChunkCoords position, int slot, ItemStack item) { + super(NetworkEventHandler.EventType.INVENTORY_UPDATE, position); + + this.slotIndex = slot; + this.itemStack = item; + } + + public EventInventoryUpdate(DataInputStream byteStream) { + super(NetworkEventHandler.EventType.INVENTORY_UPDATE, byteStream); + + this.readDataFromInputStream(byteStream); + } + + @Override + protected void writeDataToOutputStream(DataOutputStream byteStream) { + super.writeDataToOutputStream(byteStream); + + try { + byteStream.writeInt(this.slotIndex); + this.writeItemStackToData(this.itemStack, byteStream); + } catch (IOException e) { + LogHelper.error("Could not write EventInventoryUpdate to byte stream."); + e.printStackTrace(); + } + } + + @Override + protected void readDataFromInputStream(DataInputStream byteStream) { + super.readDataFromInputStream(byteStream); + + try { + this.slotIndex = byteStream.readInt(); + this.itemStack = this.readItemStackFromData(byteStream); + } catch (IOException e) { + LogHelper.error("Could not read EventInventoryUpdate to byte stream."); + e.printStackTrace(); + } + } + + @Override + public void process(EntityPlayerMP player) { + TileEntity tile = FMLClientHandler.instance().getClient().theWorld.getTileEntity(getCoords().x, getCoords().y, getCoords().z); + + if (tile != null && tile instanceof IInventory) { + ((IInventory) tile).setInventorySlotContents(slotIndex, itemStack); + } + } +} diff --git a/src/main/java/magicbees/main/utils/net/NetworkEventHandler.java b/src/main/java/magicbees/main/utils/net/NetworkEventHandler.java new file mode 100644 index 0000000..91ef606 --- /dev/null +++ b/src/main/java/magicbees/main/utils/net/NetworkEventHandler.java @@ -0,0 +1,125 @@ +package magicbees.main.utils.net; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + +import java.io.DataInputStream; +import java.io.IOException; + +import magicbees.main.MagicBees; +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.LogHelper; +import magicbees.main.utils.VersionInfo; +import magicbees.main.utils.error.InvalidEventTypeIndexException; +import magicbees.tileentity.AuraCharges; +import magicbees.tileentity.ITileEntityAuraCharged; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.tileentity.TileEntity; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.FMLEventChannel; +import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; +import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + +public class NetworkEventHandler { + + public static final String CHANNEL_NAME = VersionInfo.ModName; + + public static NetworkEventHandler getInstance() { + return MagicBees.object.netHandler; + } + + public enum EventType { + UNKNOWN, + INVENTORY_UPDATE, + FLAGS_UPDATE, + AURA_CHARGE_UPDATE + ; + } + + private FMLEventChannel channel; + + public NetworkEventHandler() { + channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(CHANNEL_NAME); + channel.register(this); + } + + @SubscribeEvent + public void onPacket(ServerCustomPacketEvent event) { + this.parseAndDispatchPacket(event.packet.payload(), ((NetHandlerPlayServer)event.handler).playerEntity); + } + + @SubscribeEvent + public void onPacket(ClientCustomPacketEvent event) { + this.parseAndDispatchPacket(event.packet.payload(), null); + } + + public void sendInventoryUpdate(TileEntity entity, int slotIndex, ItemStack itemStack) { + EventInventoryUpdate event = new EventInventoryUpdate(new ChunkCoords(entity), slotIndex, itemStack); + FMLProxyPacket packet = event.getPacket(); + + sendPacket(packet); + } + + public void sendFlagsUpdate(TileEntity entity, int[] flags) { + EventFlagsUpdate event = new EventFlagsUpdate(new ChunkCoords(entity), flags); + FMLProxyPacket packet = event.getPacket(); + + sendPacket(packet); + } + + public void sendAuraChargeUpdate(T entity, AuraCharges auraCharges) { + EventAuraChargeUpdate event = new EventAuraChargeUpdate(new ChunkCoords(entity), auraCharges); + FMLProxyPacket packet = event.getPacket(); + + sendPacket(packet); + } + + private void sendPacket(FMLProxyPacket packet) { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + channel.sendToAll(packet); + } + else { + channel.sendToServer(packet); + } + } + + private void parseAndDispatchPacket(ByteBuf packetPayload, EntityPlayerMP player) { + try { + DataInputStream data = new DataInputStream(new ByteBufInputStream(packetPayload)); + + processEventData(data, player); + + data.close(); + } catch (IOException e) { + LogHelper.info("DataInputStream had a problem closing. Good for it."); + //e.printStackTrace(); + } + } + + private void processEventData(DataInputStream data, EntityPlayerMP player) throws IOException { + int eventId = data.readInt(); + + if (eventId == EventType.INVENTORY_UPDATE.ordinal()) { + EventInventoryUpdate eventData = new EventInventoryUpdate(data); + eventData.process(player); + } + else if (eventId == EventType.FLAGS_UPDATE.ordinal()) { + EventFlagsUpdate eventData = new EventFlagsUpdate(data); + eventData.process(player); + } + else if (eventId == EventType.AURA_CHARGE_UPDATE.ordinal()) { + EventAuraChargeUpdate evenData = new EventAuraChargeUpdate(data); + evenData.process(player); + } + else { + throw new InvalidEventTypeIndexException(""); + } + } + +} diff --git a/src/main/java/magicbees/reference/Names.java b/src/main/java/magicbees/reference/Names.java deleted file mode 100644 index 19b1a74..0000000 --- a/src/main/java/magicbees/reference/Names.java +++ /dev/null @@ -1,13 +0,0 @@ -package magicbees.reference; - -public class Names { - public static final class Blocks - { - public static final String THAUMIC_APIARY = "thaumicApiary"; - } - - public static final class Containers - { - public static final String THAUMIC_APIARY = "container.mb." + Blocks.THAUMIC_APIARY; - } -} diff --git a/src/main/java/magicbees/tileentity/AuraCharges.java b/src/main/java/magicbees/tileentity/AuraCharges.java new file mode 100644 index 0000000..aa5edcc --- /dev/null +++ b/src/main/java/magicbees/tileentity/AuraCharges.java @@ -0,0 +1,70 @@ +package magicbees.tileentity; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import magicbees.bees.AuraChargeType; + +public class AuraCharges { + private static final String auraChargesTagName = "AuraCharges"; + + private final Map charges = new HashMap(AuraChargeType.values().length); + + public void start(AuraChargeType auraChargeType, World worldObj) { + charges.put(auraChargeType, worldObj.getTotalWorldTime()); + } + + public boolean isActive(AuraChargeType auraChargeType) { + return charges.keySet().contains(auraChargeType); + } + + public boolean isExpired(AuraChargeType auraChargeType, World worldObj) { + Long chargeStart = charges.get(auraChargeType); + return chargeStart == null || chargeStart + auraChargeType.duration <= worldObj.getTotalWorldTime(); + } + + public void stop(AuraChargeType AuraChargeType) { + charges.remove(AuraChargeType); + } + + public void writeToNBT(NBTTagCompound nbtTagCompound) { + NBTTagCompound auraChargeTags = new NBTTagCompound(); + for (Map.Entry chargeEntry : charges.entrySet()) { + String chargeName = chargeEntry.getKey().toString(); + Long chargeStart = chargeEntry.getValue(); + auraChargeTags.setLong(chargeName, chargeStart); + } + nbtTagCompound.setTag(auraChargesTagName, auraChargeTags); + } + + public void readFromNBT(NBTTagCompound nbtTagCompound) { + NBTTagCompound auraChargeTags = nbtTagCompound.getCompoundTag(auraChargesTagName); + for (AuraChargeType auraCharge : AuraChargeType.values()) { + String chargeName = auraCharge.toString(); + Long chargeStart = auraChargeTags.getLong(chargeName); + if (chargeStart > 0) { + charges.put(auraCharge, chargeStart); + } + } + } + + public int writeToFlags() { + int flags = 0; + for (AuraChargeType auraChargeType : charges.keySet()) { + flags |= auraChargeType.flag; + } + return flags; + } + + public void readFromFlags(int flags) { + charges.clear(); + for (AuraChargeType auraCharge : AuraChargeType.values()) { + if ((flags & auraCharge.flag) > 0) { + charges.put(auraCharge, 0L); + } + } + } +} diff --git a/src/main/java/magicbees/tileentity/ITileEntityAuraCharged.java b/src/main/java/magicbees/tileentity/ITileEntityAuraCharged.java new file mode 100644 index 0000000..13abd75 --- /dev/null +++ b/src/main/java/magicbees/tileentity/ITileEntityAuraCharged.java @@ -0,0 +1,5 @@ +package magicbees.tileentity; + +public interface ITileEntityAuraCharged { + AuraCharges getAuraCharges(); +} diff --git a/src/main/java/magicbees/tileentity/ITileEntityFlags.java b/src/main/java/magicbees/tileentity/ITileEntityFlags.java new file mode 100644 index 0000000..8506fac --- /dev/null +++ b/src/main/java/magicbees/tileentity/ITileEntityFlags.java @@ -0,0 +1,6 @@ +package magicbees.tileentity; + +public interface ITileEntityFlags { + + public void setFlags(int[] flags); +} diff --git a/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java b/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java new file mode 100644 index 0000000..225e7a5 --- /dev/null +++ b/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java @@ -0,0 +1,769 @@ +package magicbees.tileentity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import magicbees.bees.AuraChargeType; +import magicbees.api.bees.IMagicApiaryAuraProvider; +import magicbees.bees.BeeManager; +import magicbees.main.CommonProxy; +import magicbees.main.MagicBees; +import magicbees.main.utils.ChunkCoords; +import magicbees.main.utils.ItemStackUtils; +import magicbees.main.utils.net.EventAuraChargeUpdate; +import magicbees.main.utils.net.NetworkEventHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.Constants; + +import com.mojang.authlib.GameProfile; + +import forestry.api.apiculture.IBee; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IBeekeepingLogic; +import forestry.api.apiculture.IHiveFrame; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.ErrorStateRegistry; +import forestry.api.core.IErrorState; +import forestry.api.genetics.IIndividual; +import forestry.core.utils.Utils; + +public class TileEntityMagicApiary extends TileEntity implements ISidedInventory, IBeeHousing, ITileEntityAuraCharged { + + public static final String tileEntityName = CommonProxy.DOMAIN + ".magicApiary"; + private GameProfile ownerProfile; + + // Constants + private static final int SLOT_QUEEN = 0; + private static final int SLOT_DRONE = 1; + private static final int SLOT_FRAME_START = 2; + private static final int SLOT_FRAME_COUNT = 3; + private static final int SLOT_PRODUCTS_START = 5; + private static final int SLOT_PRODUCTS_COUNT = 7; + + private static final int AURAPROVIDER_SEARCH_RADIUS = 6; + + private IBeekeepingLogic logic; + private IMagicApiaryAuraProvider auraProvider; + private ChunkCoords auraProviderPosition; + private BiomeGenBase biome; + private int displayHealthMax = 0; + private int displayHealth = 0; + private boolean init = false; + + private final AuraCharges auraCharges = new AuraCharges(); + + private IErrorState errorState = ErrorStateRegistry.getErrorState("ok"); + + private ItemStack[] items; + + public TileEntityMagicApiary(){ + items = new ItemStack[12]; + logic = BeeManager.beeRoot.createBeekeepingLogic(this); + } + + public void setOwner(EntityPlayer player) { + this.ownerProfile = player.getGameProfile(); + } + + @Override + public ItemStack getQueen() { + return getStackInSlot(SLOT_QUEEN); + } + + @Override + public ItemStack getDrone() { + return getStackInSlot(SLOT_DRONE); + } + + @Override + public void setQueen(ItemStack itemstack) { + setInventorySlotContents(SLOT_QUEEN, itemstack); + } + + @Override + public void setDrone(ItemStack itemstack) { + setInventorySlotContents(SLOT_DRONE, itemstack); + } + + @Override + public boolean canBreed() { + return true; + } + + @Override + public void onQueenChange(ItemStack queenStack) { + if (!worldObj.isRemote) { + MagicBees.object.netHandler.sendInventoryUpdate(this, SLOT_QUEEN, queenStack); + } + } + + @Override + public void wearOutEquipment(int amount) { + int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier()); + + for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) { + if (getStackInSlot(i) == null) { + continue; + } + if (!(getStackInSlot(i).getItem() instanceof IHiveFrame)) { + continue; + } + + setInventorySlotContents(i, ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i), + BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)), wear)); + } + } + + @Override + public void onQueenDeath(IBee queen) { + + } + + @Override + public void onPostQueenDeath(IBee queen) { + + } + + @Override + public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) { + return false; + } + + @Override + public boolean onEggLaid(IBee queen) { + return false; + } + + private boolean isItemStackFrame(int i) { + return getStackInSlot(i) != null && getStackInSlot(i).getItem() instanceof IHiveFrame; + } + + @Override + public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { + float mod = 1.0f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) { + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getTerritoryModifier(genome, mod); + } + } + return mod; + } + + @Override + public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + float mod = 1.0f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) { + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getMutationModifier(genome, mate, mod); + } + } + if (this.isMutationBoosted()) { + mod = mod * 2f; + } + return mod; + } + + @Override + public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + float mod = 1.0f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) { + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getLifespanModifier(genome, mate, mod); + } + } + if (this.isDeathRateBoosted()) { + mod = mod / 2f; + } + return mod; + } + + @Override + public float getProductionModifier(IBeeGenome genome, float currentModifier) { + float mod = 0.9f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++){ + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getProductionModifier(genome, mod); + } + } + if (this.isProductionBoosted()) { + mod = mod * 2f; + } + return mod; + } + + @Override + public float getFloweringModifier(IBeeGenome genome, float currentModifier) { + float mod = 1.0f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) { + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getFloweringModifier(genome, mod); + } + } + return mod; + } + + @Override + public float getGeneticDecay(IBeeGenome genome, float currentModifier) { + float mod = 0.8f; + for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) { + if (isItemStackFrame(slotIndex)) { + mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getGeneticDecay(genome, mod); + } + } + return mod; + } + + @Override + public boolean isSealed() { + return false; + } + + @Override + public boolean isSelfLighted() { + return false; + } + + @Override + public boolean isSunlightSimulated() { + return false; + } + + @Override + public boolean isHellish() { + return false; + } + + @Override + public GameProfile getOwnerName() { + return this.ownerProfile; + } + + @Override + public World getWorld() { + return worldObj; + } + + @Override + public int getXCoord() { + return xCoord; + } + + @Override + public int getYCoord() { + return yCoord; + } + + @Override + public int getZCoord() { + return zCoord; + } + + @Override + public int getBiomeId() { + return biome.biomeID; + } + + @Override + public BiomeGenBase getBiome() { + return biome; + } + + @Override + public EnumTemperature getTemperature() { + return EnumTemperature.getFromValue(getExactTemperature()); + } + + @Override + public EnumHumidity getHumidity() { + return EnumHumidity.getFromValue(getExactHumidity()); + } + + @Override + public void setErrorState(int state) { + this.errorState = ErrorStateRegistry.getErrorState((short) state); + } + + @Override + public void setErrorState(IErrorState state) { + this.errorState = state; + } + + @Override + public int getErrorOrdinal() { + return this.errorState.getID(); + } + + @Override + public IErrorState getErrorState() { + return this.errorState; + } + + @Override + public boolean addProduct(ItemStack product, boolean all) { + int countAdded = ItemStackUtils.addItemToInventory(this, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT); + + if (all) { + return countAdded == product.stackSize; + } + else { + return countAdded > 0; + } + } + + @Override + public int getSizeInventory() { + return items.length; + } + + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + ItemStack itemStack = getStackInSlot(i); + + if (itemStack != null) { + if (itemStack.stackSize <= j) { + setInventorySlotContents(i, null); + }else{ + itemStack = itemStack.splitStack(j); + markDirty(); + } + } + + return itemStack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + setInventorySlotContents(i, null); + return item; + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemStack) { + items[i] = itemStack; + + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()){ + itemStack.stackSize = getInventoryStackLimit(); + } + + markDirty(); + } + + @Override + public String getInventoryName() { + return tileEntityName; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { + return entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemStack) { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int slot, ItemStack itemStack, int side) { + if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack) + && !BeeManager.beeRoot.isDrone(itemStack)) { + return true; + } + else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) { + return true; + } + return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack itemStack, int side) { + switch (slot){ + case SLOT_QUEEN: + case SLOT_DRONE: + case SLOT_FRAME_START: + case SLOT_FRAME_START + 1: + case SLOT_FRAME_START + 2: + return false; + default: + return true; + } + + } + + private int getHealthDisplay() { + if (getStackInSlot(SLOT_QUEEN) == null) { + return 0; + } + + if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) { + return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getHealth(); + } + else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) { + return displayHealth; + } + else { + return 0; + } + } + + private int getMaxHealthDisplay() { + if (getStackInSlot(SLOT_QUEEN) == null) { + return 0; + } + if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) { + return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth(); + } + else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) { + return displayHealthMax; + } + else { + return 0; + } + } + + public int getHealthScaled(int i) { + if (getMaxHealthDisplay() == 0) { + return 0; + } + + return (getHealthDisplay() * i) / getMaxHealthDisplay(); + } + + public int getTemperatureScaled(int i) { + return Math.round(i * (getExactTemperature() / 2)); + } + + public int getHumidityScaled(int i) { + return Math.round(i * getExactHumidity()); + } + + /* Saving and loading */ + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + NBTTagList items = new NBTTagList(); + + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack itemStack = getStackInSlot(i); + + if (itemStack != null) { + NBTTagCompound item = new NBTTagCompound(); + item.setByte("Slot", (byte)i); + itemStack.writeToNBT(item); + items.appendTag(item); + } + } + compound.setTag("Items", items); + + compound.setInteger("BiomeId", biome.biomeID); + if (logic != null) { + logic.writeToNBT(compound); + } + + ChunkCoords.writeToNBT(this.auraProviderPosition, compound); + + auraCharges.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < items.tagCount(); i++) { + NBTTagCompound item = items.getCompoundTagAt(i); + int slot = item.getByte("Slot"); + + if (slot >= 0 && slot < getSizeInventory()) { + setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item)); + } + } + + int biomeId = compound.getInteger("BiomeId"); + biome = BiomeGenBase.getBiome(biomeId); + logic.readFromNBT(compound); + + this.auraProviderPosition = ChunkCoords.readFromNBT(compound); + + auraCharges.readFromNBT(compound); + } + + @Override + public Packet getDescriptionPacket() { + EventAuraChargeUpdate event = new EventAuraChargeUpdate(new ChunkCoords(this), auraCharges); + return event.getPacket(); + } + + public float getExactTemperature() { + return biome.temperature; + } + + public float getExactHumidity() { + return biome.rainfall; + } + + @Override + public void updateEntity() { + if (!init) { + init = true; + updateBiome(); + } + + if (worldObj.isRemote) { + updateClientSide(); + } + else { + updateServerSide(); + } + } + + public void updateBiome() { + if (worldObj != null) { + if (biome == null) { + BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, yCoord); + if (biome != null) { + this.biome = biome; + setErrorState(ErrorStateRegistry.getErrorState("OK")); + } + } + } + } + + public void updateClientSide() { + if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) { + if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 10 == 0) { + IBee displayQueen = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)); + displayQueen.doFX(logic.getEffectData(), this); + } + } + } + + public void updateServerSide() { + if (this.auraProvider == null) { + findAuraProvider(); + } + else { + updateAuraProvider(); + } + tickCharges(); + + logic.update(); + + IBee queen = logic.getQueen(); + if (queen == null) { + return; + } + + if (worldObj.getTotalWorldTime() % 5 == 0) { + onQueenChange(getStackInSlot(SLOT_QUEEN)); + } + } + + public void getGUINetworkData(int i, int j) { + if (logic == null) { + return; + } + + switch(i) { + case 0: + displayHealth = j; + break; + case 1: displayHealthMax = j; + break; + } + } + + public void sendGUINetworkData(Container container, ICrafting iCrafting) { + if (logic == null) { + return; + } + + iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime()); + iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime()); + } + + public boolean isProductionBoosted() { + return auraCharges.isActive(AuraChargeType.PRODUCTION); + } + + public boolean isDeathRateBoosted() { + return auraCharges.isActive(AuraChargeType.DEATH); + } + + public boolean isMutationBoosted() { + return auraCharges.isActive(AuraChargeType.MUTATION); + } + + private void updateAuraProvider() { + if (worldObj.getTotalWorldTime() % 10 != 0) { + return; + } + if (getAuraProvider(auraProviderPosition) == null) { + this.auraProvider = null; + this.auraProviderPosition = null; + return; + } + + boolean auraChargesChanged = false; + for (AuraChargeType chargeType : AuraChargeType.values()) { + if (!auraCharges.isActive(chargeType) && auraProvider.getCharge(chargeType)) { + auraCharges.start(chargeType, worldObj); + auraChargesChanged = true; + } + } + + if (auraChargesChanged) { + NetworkEventHandler.getInstance().sendAuraChargeUpdate(this, auraCharges); + } + } + + private void tickCharges() { + boolean auraChargesChanged = false; + + for (AuraChargeType chargeType : AuraChargeType.values()) { + if (auraCharges.isActive(chargeType) && auraCharges.isExpired(chargeType, worldObj) && (auraProvider == null || !auraProvider.getCharge(chargeType))) { + auraCharges.stop(chargeType); + auraChargesChanged = true; + } + } + + if (auraChargesChanged) { + NetworkEventHandler.getInstance().sendAuraChargeUpdate(this, auraCharges); + } + } + + private void findAuraProvider() { + if (worldObj.getTotalWorldTime() % 5 != 0) { + return; + } + + if (this.auraProviderPosition == null) { + List chunks = getChunksInSearchRange(); + for (Chunk chunk : chunks) { + if (searchChunkForBooster(chunk)) { + break; + } + } + } else { + this.auraProvider = getAuraProvider(auraProviderPosition); + if (auraProvider == null) { + this.auraProviderPosition = null; + } + } + } + + private List getChunksInSearchRange() { + List chunks = new ArrayList(4); + chunks.add(worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS)); + Chunk chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + chunk = worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + return chunks; + } + + private boolean searchChunkForBooster(Chunk chunk) { + Vec3 apiaryPos = Vec3.createVectorHelper(xCoord, yCoord, zCoord); + for (Map.Entry entry : ((Map)chunk.chunkTileEntityMap).entrySet()) { + TileEntity entity = entry.getValue(); + if (entity instanceof IMagicApiaryAuraProvider) { + Vec3 tePos = Vec3.createVectorHelper(entity.xCoord, entity.yCoord, entity.zCoord); + Vec3 result = apiaryPos.subtract(tePos); + if (result.lengthVector() <= AURAPROVIDER_SEARCH_RADIUS) { + saveAuraProviderPosition(entity.xCoord, entity.yCoord, entity.zCoord); + this.auraProvider = (IMagicApiaryAuraProvider)entity; + return true; + } + } + } + return false; + } + + private void saveAuraProviderPosition(int x, int y, int z) { + auraProviderPosition = new ChunkCoords(worldObj.provider.dimensionId, x, y, z); + } + + private IMagicApiaryAuraProvider getAuraProvider(ChunkCoords coords) { + return getAuraProvider(coords.x, coords.y, coords.z); + } + + private IMagicApiaryAuraProvider getAuraProvider(int x, int y, int z) { + Chunk chunk = worldObj.getChunkFromBlockCoords(x, z); + x %= 16; + z %= 16; + if (x < 0) { + x += 16; + } + if (z < 0) { + z += 16; + } + ChunkPosition cPos = new ChunkPosition(x, y, z); + TileEntity entity = (TileEntity)chunk.chunkTileEntityMap.get(cPos); + if (!(entity instanceof IMagicApiaryAuraProvider)) { + return null; + } + return (IMagicApiaryAuraProvider)entity; + } + + @Override + public AuraCharges getAuraCharges() { + return auraCharges; + } +} diff --git a/src/main/java/magicbees/tileentity/TileEntityThaumicApiary.java b/src/main/java/magicbees/tileentity/TileEntityThaumicApiary.java deleted file mode 100644 index 3b71520..0000000 --- a/src/main/java/magicbees/tileentity/TileEntityThaumicApiary.java +++ /dev/null @@ -1,564 +0,0 @@ -package magicbees.tileentity; - -import com.mojang.authlib.GameProfile; -import forestry.api.apiculture.*; -import forestry.api.core.ErrorStateRegistry; -import forestry.api.core.IErrorState; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.api.genetics.IIndividual; -import forestry.core.config.ForestryItem; -import forestry.core.inventory.InvTools; -import forestry.core.proxy.Proxies; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.Utils; -import forestry.plugins.PluginApiculture; -import magicbees.main.CommonProxy; -import magicbees.main.utils.LogHelper; -import magicbees.reference.Names; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.Constants; - -public class TileEntityThaumicApiary extends TileEntity implements ISidedInventory, IBeeHousing { - - public static final String tileEntityName = CommonProxy.DOMAIN + ".thaumicApiary"; - private GameProfile ownerName; - - // Constants - private static final int SLOT_QUEEN = 0; - private static final int SLOT_DRONE = 1; - private static final int SLOT_FRAME_START = 2; - private static final int SLOT_INVENTORY_START = 5; - private static final int SLOT_FRAME_COUNT = 3; - private static final int SLOT_INVENTORY_COUNT = 7; - - - private final IBeekeepingLogic logic; - private BiomeGenBase biome; - private int displayHealthMax = 0; - private int displayHealth = 0; - private boolean init = false; - - private ItemStack[] items; - - protected final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); - - public TileEntityThaumicApiary() - { - items = new ItemStack[12]; - logic = PluginApiculture.beeInterface.createBeekeepingLogic(this); - } - - public void setOwner(EntityPlayer player) { this.ownerName = player.getGameProfile(); } - - @Override - public ItemStack getQueen() { - return getStackInSlot(SLOT_QUEEN); - } - - @Override - public ItemStack getDrone() { - return getStackInSlot(SLOT_DRONE); - } - - @Override - public void setQueen(ItemStack itemstack) { - setInventorySlotContents(SLOT_QUEEN, itemstack); - } - - @Override - public void setDrone(ItemStack itemstack) { - setInventorySlotContents(SLOT_DRONE, itemstack); - } - - @Override - public boolean canBreed() { - return true; - } - - // TODO: Investigate this :D - @Override - public void onQueenChange(ItemStack queenStack) { - - } - - @Override - public void wearOutEquipment(int amount) { - int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier()); - - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (!(getStackInSlot(i).getItem() instanceof IHiveFrame)) - continue; - - setInventorySlotContents( - i, - ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i), - PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)), wear)); - } - } - - @Override - public void onQueenDeath(IBee queen) { - - } - - @Override - public void onPostQueenDeath(IBee queen) { - - } - - @Override - public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) { - return false; - } - - @Override - public boolean onEggLaid(IBee queen) { - return false; - } - - @Override - public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod); - } - return mod; - } - - @Override - public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod); - } - return mod; - } - - @Override - public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod); - } - return mod; - } - - @Override - public float getProductionModifier(IBeeGenome genome, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getProductionModifier(genome, mod); - } - return mod; - } - - @Override - public float getFloweringModifier(IBeeGenome genome, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getFloweringModifier(genome, mod); - } - return mod; - } - - @Override - public float getGeneticDecay(IBeeGenome genome, float currentModifier) { - float mod = 1.0f; - for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){ - if (getStackInSlot(i) == null) - continue; - if (getStackInSlot(i).getItem() instanceof IHiveFrame) - mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getGeneticDecay(genome, mod); - } - return mod; - } - - @Override - public boolean isSealed() { - return false; - } - - @Override - public boolean isSelfLighted() { - return false; - } - - @Override - public boolean isSunlightSimulated() { - return false; - } - - @Override - public boolean isHellish() { - return false; - } - - @Override - public GameProfile getOwnerName() { - return this.ownerName; - } - - @Override - public World getWorld() { - return worldObj; - } - - @Override - public int getXCoord() { - return xCoord; - } - - @Override - public int getYCoord() { - return yCoord; - } - - @Override - public int getZCoord() { - return zCoord; - } - - @Override - public int getBiomeId() { - return biome.biomeID; - } - - @Override - public BiomeGenBase getBiome() { - return biome; - } - - @Override - public EnumTemperature getTemperature() { - return EnumTemperature.getFromValue(getExactTemperature()); - } - - @Override - public EnumHumidity getHumidity() { - return EnumHumidity.getFromValue(getExactHumidity()); - } - - @Override - public void setErrorState(int state) { - - } - - @Override - public void setErrorState(IErrorState state) { - - } - - @Override - public int getErrorOrdinal() { - return 0; - } - - @Override - public IErrorState getErrorState() { - return null; - } - - public InventoryAdapter getInternalInventory() { - return inventory; - } - - // TODO: Implement own version of this - @Override - public boolean addProduct(ItemStack product, boolean all) { - LogHelper.info("Trying to add " + product.getDisplayName() + " to thaumicApiary"); - return InvTools.tryAddStack(getInternalInventory(), product, SLOT_INVENTORY_START, SLOT_INVENTORY_COUNT, all, true); - } - - @Override - public int getSizeInventory() { - return items.length; - } - - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack itemStack = getStackInSlot(i); - - if (itemStack != null) { - if (itemStack.stackSize <= j) { - setInventorySlotContents(i, null); - }else{ - itemStack = itemStack.splitStack(j); - markDirty(); - } - } - - return itemStack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - setInventorySlotContents(i, null); - return item; - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemStack) { - items[i] = itemStack; - - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()){ - itemStack.stackSize = getInventoryStackLimit(); - } - - markDirty(); - } - - @Override - public String getInventoryName() { - return Names.Containers.THAUMIC_APIARY; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) { - return entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64; - } - - @Override - public void openInventory() { - - } - - @Override - public void closeInventory() { - - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemStack) { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return new int[0]; - } - - @Override - public boolean canInsertItem(int slot, ItemStack itemStack, int side) { - if(slot == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemStack) - && !PluginApiculture.beeInterface.isDrone(itemStack)) - return true; - return slot == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemStack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack itemStack, int side) { - switch (slot){ - case SLOT_QUEEN: - case SLOT_DRONE: - case SLOT_FRAME_START: - case SLOT_FRAME_START + 1: - case SLOT_FRAME_START + 2: - return false; - default: - return true; - } - - } - - /* Health display */ - private int getHealthDisplay(){ - if (getStackInSlot(SLOT_QUEEN) == null) - return 0; - - if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) - return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getHealth(); - else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) - return displayHealth; - else - return 0; - } - - private int getMaxHealthDisplay(){ - if (getStackInSlot(SLOT_QUEEN) == null) - return 0; - if (ForestryItem.beeQueenGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) - return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth(); - else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) - return displayHealthMax; - else - return 0; - } - - private int getHealthScaled(int i){ - if (getMaxHealthDisplay() == 0) - return 0; - - return (getHealthDisplay() * i) / getMaxHealthDisplay(); - } - - public int getTemperatureScaled(int i) { - return Math.round(i * (getExactTemperature() / 2)); - } - - public int getHumidityScaled(int i) { - return Math.round(i * getExactHumidity()); - } - - /* Saving and loading */ - @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - - NBTTagList items = new NBTTagList(); - - for (int i = 0; i < getSizeInventory(); i++){ - ItemStack itemStack = getStackInSlot(i); - - if (itemStack != null){ - NBTTagCompound item = new NBTTagCompound(); - item.setByte("Slot", (byte)i); - itemStack.writeToNBT(item); - items.appendTag(item); - } - } - - compound.setInteger("BiomeId", biome.biomeID); - if (logic != null) - logic.writeToNBT(compound); - - compound.setTag("Items", items); - } - - @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); - - NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < items.tagCount(); i++){ - NBTTagCompound item = (NBTTagCompound)items.getCompoundTagAt(i); - int slot = item.getByte("Slot"); - - if (slot >= 0 && slot < getSizeInventory()){ - setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item)); - } - } - - int biomeId = compound.getInteger("BiomeId"); - biome = BiomeGenBase.getBiome(biomeId); - logic.readFromNBT(compound); - } - - public float getExactTemperature(){ - return biome.temperature; - } - - public float getExactHumidity(){ - return biome.rainfall; - } - - @Override - public void updateEntity(){ - if (init == false){ - init = true; - updateBiome(); - } - - if (!Proxies.common.isSimulating(worldObj)) - updateClientSide(); - else - updateServerSide(); - } - - public void updateBiome(){ - if (worldObj != null){ - if (biome == null){ - BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, yCoord); - if (biome != null){ - this.biome = biome; - setErrorState(ErrorStateRegistry.getErrorState("OK")); - } - } - } - } - - public void updateClientSide(){ - if (PluginApiculture.beeInterface.isMated(getStackInSlot(SLOT_QUEEN))) { - if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 2 % 2 == 0) { - IBee displayQueen = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)); - displayQueen.doFX(logic.getEffectData(), this); - } - } - } - - public void updateServerSide(){ - logic.update(); - - IBee queen = logic.getQueen(); - if (queen == null) - return; - - // Swarm effects - if (worldObj.getTotalWorldTime() % 200 * 10 == 0) - onQueenChange(getStackInSlot(SLOT_QUEEN)); - } - - public void getGUINetworkData(int i, int j){ - if (logic == null) - return; - - switch(i) { - case 0: - displayHealth = j; - break; - case 1: displayHealthMax = j; - break; - } - } - - public void sendGUINetworkData(Container container, ICrafting iCrafting) { - if (logic == null) - return; - - iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime()); - iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime()); - } -} diff --git a/src/main/java/magicbees/tileentity/TileEntityVisAuraProvider.java b/src/main/java/magicbees/tileentity/TileEntityVisAuraProvider.java new file mode 100644 index 0000000..e87ab48 --- /dev/null +++ b/src/main/java/magicbees/tileentity/TileEntityVisAuraProvider.java @@ -0,0 +1,125 @@ +package magicbees.tileentity; + +import java.util.HashMap; +import java.util.Map; + +import magicbees.api.bees.IAuraChargeType; +import magicbees.bees.AuraChargeType; +import magicbees.api.bees.IMagicApiaryAuraProvider; +import magicbees.main.CommonProxy; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.visnet.VisNetHandler; + +public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiaryAuraProvider { + + public static final String tileEntityName = CommonProxy.DOMAIN + ".visAuraProvider"; + + private static final int MAX_CHARGES = 10; + private static final int VIS_PER_CHARGE = 8; + + private static class AuraCharge { + int charges; + int vis; + + public int[] toArray() { + return new int[]{charges, vis}; + } + + public void fromArray(int[] array) { + if (array.length == 2) { + charges = array[0]; + vis = array[1]; + } + } + } + + private final Map currentCharges; + + public TileEntityVisAuraProvider() { + super(); + + AuraChargeType[] auraChargeTypes = AuraChargeType.values(); + currentCharges = new HashMap(auraChargeTypes.length); + for (AuraChargeType auraChargeType : auraChargeTypes) { + currentCharges.put(auraChargeType, new AuraCharge()); + } + } + + @Override + public void updateEntity() { + + long tick = worldObj.getTotalWorldTime(); + + for (Map.Entry currentCharge : currentCharges.entrySet()) { + AuraChargeType type = currentCharge.getKey(); + AuraCharge auraCharge = currentCharge.getValue(); + + if (auraCharge.charges < MAX_CHARGES && (tick % type.tickRate) == 0) { + auraCharge.vis += getVisFromNet(type.aspect); + if (auraCharge.vis >= VIS_PER_CHARGE) { + auraCharge.vis -= VIS_PER_CHARGE; + auraCharge.charges++; + } + } + } + } + + private int getVisFromNet(Aspect aspect) { + return VisNetHandler.drainVis(worldObj, xCoord, yCoord, zCoord, aspect, 1); + } + + @Override + public boolean getMutationCharge() { + return getCharge(AuraChargeType.MUTATION); + } + + @Override + public boolean getDeathRateCharge() { + return getCharge(AuraChargeType.DEATH); + } + + @Override + public boolean getProductionCharge() { + return getCharge(AuraChargeType.PRODUCTION); + } + + @Override + public boolean getCharge(IAuraChargeType auraChargeType) { + AuraCharge auraCharge = currentCharges.get(auraChargeType); + if (auraCharge == null) { + return false; + } + if (auraCharge.charges > 0) { + auraCharge.charges--; + return true; + } + + return false; + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + + for (Map.Entry charge : currentCharges.entrySet()) { + String auraName = charge.getKey().toString(); + int[] array = tag.getIntArray(auraName); + AuraCharge auraCharge = charge.getValue(); + auraCharge.fromArray(array); + } + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + + for (Map.Entry charge : currentCharges.entrySet()) { + String auraName = charge.getKey().toString(); + AuraCharge auraCharge = charge.getValue(); + int[] array = auraCharge.toArray(); + tag.setIntArray(auraName, array); + } + } +} diff --git a/src/main/resources/assets/magicbees/lang/en_US.lang b/src/main/resources/assets/magicbees/lang/en_US.lang index d80903f..e2a52d8 100644 --- a/src/main/resources/assets/magicbees/lang/en_US.lang +++ b/src/main/resources/assets/magicbees/lang/en_US.lang @@ -10,11 +10,9 @@ item.magicbees:mysteriousMagnet.name=Mysterious Magnet item.moonDial.name=Jade Moon Dial #Tiles -tile.planks.greatwood.name=Greatwood Planks -tile.slab.wood.greatwood.name=Greatwood Slab -tile.planks.silverwood.name=Silverwood Planks -tile.slab.wood.silverwood.name=Silverwood Slab tile.effectJar.name=Bee Collector's Jar +tile.magicApiary.name=Magic Apiary +tile.visAuraProvider.name=Vis Apiary Booster tile.hive.curious.name=Curious Hive tile.hive.unusual.name=Unusual Hive tile.hive.deep.name=Deep Hive @@ -516,3 +514,7 @@ tc.research_page.MB_DimensionalSingularity.1=While it may appear similar to the tc.research_name.MB_EssenceOblivion=Essence of Scornful Oblivion tc.research_text.MB_EssenceOblivion=[MB] Cast aside with malice tc.research_page.MB_EssenceOblivion.1=Breeding bees for mutations can be aggrivating, especially whith long-lived species. With a little cleverness and only the slightest hint of smugness, you have found a way to utilize the Dimensional Singularity in a manner that only sucks away the life force of your tiny flying friends, bit by bit. Well, maybe significant amounts all at once. It's probably not going to affect them too badly.
It may be somewhat tricky to obtain more than one of the §5Dragon Eggs§0 nessecary to obtain more than one of these. Perhaps there is a bee species that can assist with the limitation. + +tc.research_name.MB_VisAuraProvider=Vis Apiary Booster +tc.research_text.MB_VisAuraProvider=[MB]Vis? What about Bis? +tc.research_page.MB_VisAuraProvider.1=Blah blah blah. \ No newline at end of file diff --git a/src/main/resources/assets/magicbees/model/visAuraConverter.obj b/src/main/resources/assets/magicbees/model/visAuraConverter.obj new file mode 100644 index 0000000..3fc3271 --- /dev/null +++ b/src/main/resources/assets/magicbees/model/visAuraConverter.obj @@ -0,0 +1,204 @@ +# Blender v2.61 (sub 0) OBJ File: 'vis aura converter.blend' +# www.blender.org +o centre +v 0.054523 0.500000 0.504520 +v 0.500000 0.500000 0.949997 +v 0.500000 0.500000 0.059043 +v 0.945477 0.500000 0.504520 +v 0.500000 0.905000 0.504520 +v 0.500000 0.095000 0.504520 +vt 0.500000 0.625000 +vt 1.000000 0.312500 +vt 0.926953 0.782642 +vt 0.693306 0.646921 +vt 0.979384 0.489453 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.769790 0.501479 +vt 0.468750 0.000000 +vt 0.000000 0.250000 +vt 0.000000 0.000000 +vt 0.255720 0.132285 +vt 0.437500 0.468750 +vt 0.000000 0.625000 +vt 0.556041 0.266028 +s off +f 6/1 1/2 3/3 +f 3/4 1/5 5/6 +f 5/7 1/8 2/9 +f 2/9 1/2 6/1 +f 4/10 5/11 2/12 +f 6/1 4/10 2/9 +f 3/13 5/14 4/10 +f 6/1 3/15 4/10 +o frame +v 0.250000 0.000000 1.004520 +v 0.250000 0.000000 0.754520 +v 0.750000 0.000000 0.754520 +v 0.750000 0.000000 1.004520 +v 0.250000 0.250000 1.004520 +v 0.000000 0.250000 1.004520 +v 0.000000 0.000000 1.004520 +v 0.750000 0.750000 1.004520 +v 1.000000 0.750000 1.004520 +v 1.000000 1.000000 1.004520 +v 0.750000 1.000000 1.004520 +v 0.250000 0.750000 1.004520 +v 0.000000 0.750000 1.004520 +v 0.750000 1.000000 0.754520 +v 1.000000 1.000000 0.754520 +v 0.250000 1.000000 1.004520 +v 0.000000 1.000000 1.004520 +v 0.000000 0.750000 0.754520 +v 0.000000 1.000000 0.754520 +v 1.000000 0.250000 0.254520 +v 1.000000 0.000000 0.254520 +v 1.000000 0.000000 0.004520 +v 1.000000 0.250000 0.004520 +v 1.000000 1.000000 0.254520 +v 1.000000 0.750000 0.254520 +v 1.000000 0.750000 0.004520 +v 1.000000 1.000000 0.004520 +v 0.000000 0.750000 0.254520 +v 0.000000 1.000000 0.254520 +v 0.000000 1.000000 0.004520 +v 0.000000 0.750000 0.004520 +v 0.000000 0.250000 0.004520 +v 0.250000 0.250000 0.004520 +v 0.250000 0.000000 0.004520 +v 0.000000 0.000000 0.004520 +v 0.250000 1.000000 0.004520 +v 0.750000 1.000000 0.004520 +v 0.750000 1.000000 0.254520 +v 0.250000 1.000000 0.254520 +v 0.750000 0.000000 0.004520 +v 0.750000 0.250000 0.004520 +v 0.250000 0.750000 0.004520 +v 0.250000 0.750000 0.254520 +v 0.250000 0.000000 0.254520 +v 0.000000 0.000000 0.254520 +v 0.000000 0.250000 0.254520 +v 0.750000 0.750000 0.254520 +v 0.750000 0.750000 0.004520 +v 0.750000 0.250000 0.254520 +v 0.250000 0.250000 0.254520 +v 0.750000 0.000000 0.254520 +v 0.000000 0.250000 0.754520 +v 0.000000 0.000000 0.754520 +v 1.000000 0.000000 0.754520 +v 1.000000 0.000000 1.004520 +v 0.750000 0.750000 0.754520 +v 0.750000 0.250000 1.004520 +v 1.000000 0.250000 1.004520 +v 1.000000 0.250000 0.754520 +v 1.000000 0.750000 0.754520 +v 0.250000 1.000000 0.754520 +v 0.250000 0.750000 0.754520 +v 0.750000 0.250000 0.754520 +v 0.250000 0.250000 0.754520 +vt 0.125000 0.875000 +vt 0.125000 1.000000 +vt 0.375000 1.000000 +vt 0.375000 0.875000 +vt 0.500000 1.000000 +vt 0.500000 0.875000 +vt 0.000000 0.625000 +vt 0.125000 0.625000 +vt 0.125000 0.750000 +vt 0.000000 0.750000 +vt 0.375000 0.750000 +vt 0.375000 0.625000 +vt 0.500000 0.625000 +vt 0.500000 0.750000 +vt 0.000000 1.000000 +vt 0.000000 0.875000 +vt 0.750000 1.000000 +vt 0.750000 0.875000 +vt 0.625000 1.000000 +vt 0.750000 0.750000 +vt 0.625000 0.750000 +vt 0.562500 1.000000 +vt 0.687500 1.000000 +vt 0.687500 0.750000 +vt 0.562500 0.750000 +vt 0.750000 0.906250 +vt 0.500000 0.906250 +vt 0.593750 1.000000 +vt 0.593750 0.750000 +vt 0.750000 0.812500 +vt 0.750000 0.937500 +vt 0.500000 0.937500 +vt 0.500000 0.812500 +s off +f 7/16 8/17 9/18 10/19 +f 13/20 7/18 11/19 12/21 +f 14/20 15/18 16/19 17/21 +f 12/17 11/16 18/19 19/18 +f 20/22 17/23 16/24 21/25 +f 19/26 18/27 22/28 23/29 +f 24/17 19/30 23/31 25/16 +f 26/20 27/18 28/19 29/21 +f 30/28 31/29 32/26 33/27 +f 34/28 35/29 36/26 37/27 +f 38/26 39/29 40/21 41/19 +f 42/16 45/17 44/18 43/19 +f 46/16 47/31 29/25 28/24 +f 39/24 38/16 37/19 48/26 +f 48/31 37/25 36/24 42/16 +f 50/19 51/18 41/20 40/21 +f 51/24 52/16 38/31 41/25 +f 39/21 56/20 55/32 47/33 +f 12/26 58/29 59/21 13/19 +f 8/29 7/21 13/19 59/26 +f 31/34 53/32 55/35 26/36 +f 10/25 9/24 60/16 61/31 +f 63/24 64/16 15/19 14/26 +f 65/16 64/31 61/25 60/24 +f 63/30 10/31 61/16 64/17 +f 15/24 66/25 21/22 16/23 +f 22/19 67/21 25/20 23/18 +f 67/16 22/24 17/26 20/19 +f 60/16 9/17 57/18 27/19 +f 25/27 67/26 45/24 35/23 +f 20/18 21/19 30/16 44/17 +f 57/19 50/16 40/17 46/18 +f 27/17 57/30 46/31 28/16 +f 35/20 45/18 42/19 36/21 +f 44/16 30/17 33/30 43/31 +f 8/26 59/27 51/23 50/24 +f 29/26 47/19 54/16 32/24 +f 32/20 54/18 43/19 33/21 +f 65/37 69/38 62/39 66/40 +f 70/20 68/29 18/36 11/34 +f 68/21 49/33 45/32 67/20 +f 56/29 39/20 48/34 49/36 +f 8/24 50/26 56/27 70/23 +f 34/41 49/32 68/20 24/42 +f 52/43 56/20 49/29 34/44 +f 24/35 68/36 70/34 58/32 +f 58/35 70/33 56/21 52/29 +f 63/20 14/29 62/36 69/34 +f 69/16 55/19 57/18 9/17 +f 20/20 44/32 53/33 62/21 +f 53/39 54/44 47/43 55/38 +f 26/35 55/33 69/21 65/29 +f 66/21 62/20 53/32 31/33 +f 50/24 57/26 55/27 56/23 +f 53/35 44/33 45/21 49/29 +f 54/45 53/46 49/47 48/48 +f 70/24 69/26 9/27 8/23 +f 68/35 67/33 20/21 62/29 +f 18/21 68/20 62/32 14/33 +f 63/46 69/45 70/48 11/47 +f 17/26 22/24 18/23 14/27 +f 11/16 7/17 10/18 63/19 +f 65/18 60/17 27/16 26/19 +f 15/19 64/16 65/17 66/18 +f 31/26 26/24 29/16 32/19 +f 31/26 30/27 21/23 66/24 +f 43/19 54/18 48/17 42/16 +f 40/24 39/16 47/19 46/26 +f 34/19 37/26 38/24 52/16 +f 24/26 58/24 12/16 19/19 +f 35/23 34/24 24/26 25/27 +f 52/16 51/17 59/18 58/19 diff --git a/src/main/resources/assets/magicbees/model/visAuraProvider.png b/src/main/resources/assets/magicbees/model/visAuraProvider.png new file mode 100644 index 0000000..48b9909 Binary files /dev/null and b/src/main/resources/assets/magicbees/model/visAuraProvider.png differ diff --git a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.1.png b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.1.png index 1ae178c..4feeccb 100644 Binary files a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.1.png and b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.1.png differ diff --git a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.2.png b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.2.png index 1d38df9..bc573f9 100644 Binary files a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.2.png and b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.2.png differ diff --git a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.4.png b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.4.png index 02c4342..3fdcfa3 100644 Binary files a/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.4.png and b/src/main/resources/assets/magicbees/textures/blocks/thaumicapiary.4.png differ diff --git a/src/main/resources/assets/magicbees/textures/gui/apiary.png b/src/main/resources/assets/magicbees/textures/gui/apiary.png index 0220873..720edde 100644 Binary files a/src/main/resources/assets/magicbees/textures/gui/apiary.png and b/src/main/resources/assets/magicbees/textures/gui/apiary.png differ