diff --git a/magicbees_res/changelog.txt b/magicbees_res/changelog.txt index 4ada2c9..509cef0 100644 --- a/magicbees_res/changelog.txt +++ b/magicbees_res/changelog.txt @@ -1,7 +1,12 @@ 2.1.3 Added a new mini bee branch: Polymorphic. It is said Unusual bees can have some unusual effects on the world if they are advanced... +Altered mutation to get Minium bees to fit into the Polymorphic branch. Crumbling effect ages the area around the hive. -Transmutation effect will turn blocks into other blocks. (It's still a bit rough though.) +Added an IMC Handler to allow other mods to send an IMC message with key 'addCrumblePair" and a value containing two NBT tags + 'source' and 'target' for ItemStacks of the source block and target block. Blocks added on a first-come-first-serve basis. + Only one entry per source block is accepted. Several vanilla defaults are provided, can be overridden using IMC. +Changing humidity tolerance of Sorcerous bees to be actually useful. +Fixed issues with the bee effects rendering (the little bee icons that shoot out of the bee machine while they work) for custom effects. 2.1.2 Fixed issue with mob spawning effects incorrectly checking for effect data variables. diff --git a/magicbees_src/magicbees/bees/Allele.java b/magicbees_src/magicbees/bees/Allele.java index cf0a904..fc373fe 100644 --- a/magicbees_src/magicbees/bees/Allele.java +++ b/magicbees_src/magicbees/bees/Allele.java @@ -4,8 +4,8 @@ import magicbees.main.utils.LocalizationManager; import magicbees.main.utils.compat.ArsMagicaHelper; import magicbees.main.utils.compat.ThaumcraftHelper; import net.minecraft.potion.Potion; +import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IAlleleBeeSpecies; -import forestry.api.apiculture.IBeeRoot; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleEffect; @@ -16,6 +16,8 @@ public class Allele implements IAllele { public static AlleleFloat speedBlinding; + public static IAlleleBeeEffect forestryBaseEffect; + public static IAlleleFlowers flowerBookshelf; public static IAlleleFlowers flowerThaumcraft; public static IAlleleFlowers flowerArsMagica; @@ -44,7 +46,9 @@ public class Allele implements IAllele public static IAlleleEffect effectNodeCharge; public static void setupAdditionalAlleles() - { + { + forestryBaseEffect = (IAlleleBeeEffect)getBaseAllele("effectNone"); + Allele.speedBlinding = new AlleleFloat("speedBlinding", 2f, false); Allele.flowerBookshelf = new AlleleFlower("Bookshelf", new FlowerProviderBookshelf(), true); diff --git a/magicbees_src/magicbees/bees/AlleleEffect.java b/magicbees_src/magicbees/bees/AlleleEffect.java index c537acc..bbd5d5f 100644 --- a/magicbees_src/magicbees/bees/AlleleEffect.java +++ b/magicbees_src/magicbees/bees/AlleleEffect.java @@ -61,16 +61,7 @@ public abstract class AlleleEffect extends Allele implements IAlleleBeeEffect @Override public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { - int[] area = genome.getTerritory(); - float mod = housing.getTerritoryModifier(genome, 1f); - // Check to make sure territory is at least 1 with housing modifications - area[0] = Math.max((int)(area[0] * mod), 1); - area[1] = Math.max((int)(area[1] * mod), 1); - area[2] = Math.max((int)(area[2] * mod), 1); - - MagicBees.proxy.drawBeeEffects(housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), - genome.getPrimary().getIconColour(0), area[0], area[1], area[2]); - return storedData; + return Allele.forestryBaseEffect.doFX(genome, storedData, housing); } protected List getEntitiesWithinRange(IBeeGenome genome, IBeeHousing housing) diff --git a/magicbees_src/magicbees/bees/AlleleEffectCrumbling.java b/magicbees_src/magicbees/bees/AlleleEffectCrumbling.java index 496da02..37398d1 100644 --- a/magicbees_src/magicbees/bees/AlleleEffectCrumbling.java +++ b/magicbees_src/magicbees/bees/AlleleEffectCrumbling.java @@ -12,20 +12,35 @@ import forestry.api.genetics.IEffectData; public class AlleleEffectCrumbling extends AlleleEffect { - private HashMap crumbleMap; + private static HashMap crumbleMap = new HashMap(); + + public static void addPairToMap(ItemStack source, ItemStack target) + { + boolean add = true; + for (ItemStack i : crumbleMap.keySet()) + { + if (OreDictionary.itemMatches(i, source, false)) + { + add = false; + break; + } + } + if (add) + { + crumbleMap.put(source, target); + } + } public AlleleEffectCrumbling(String id, boolean isDominant) { - super(id, isDominant, 200); + super(id, isDominant, 600); - crumbleMap = new HashMap(); - - crumbleMap.put(new ItemStack(Block.stone), new ItemStack(Block.cobblestone)); - crumbleMap.put(new ItemStack(Block.cobblestone), new ItemStack(Block.cobblestoneMossy)); - crumbleMap.put(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2)); - crumbleMap.put(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stoneBrick, 1, 1)); - crumbleMap.put(new ItemStack(Block.cobblestoneWall), new ItemStack(Block.cobblestoneWall, 1, 1)); - crumbleMap.put(new ItemStack(Block.gravel), new ItemStack(Block.sand)); + addPairToMap(new ItemStack(Block.stone), new ItemStack(Block.cobblestone)); + addPairToMap(new ItemStack(Block.cobblestone), new ItemStack(Block.cobblestoneMossy)); + addPairToMap(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2)); + addPairToMap(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stoneBrick, 1, 1)); + addPairToMap(new ItemStack(Block.cobblestoneWall), new ItemStack(Block.cobblestoneWall, 1, 1)); + addPairToMap(new ItemStack(Block.gravel), new ItemStack(Block.sand)); } @Override diff --git a/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java b/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java index 346a1df..7666368 100644 --- a/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java +++ b/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java @@ -18,7 +18,7 @@ public class AlleleEffectTransmuting extends AlleleEffect { public AlleleEffectTransmuting(String id, boolean isDominant) { - super(id, isDominant, 200); + super(id, isDominant, 900); } @Override diff --git a/magicbees_src/magicbees/bees/BeeGenomeManager.java b/magicbees_src/magicbees/bees/BeeGenomeManager.java index fff0efc..805a154 100644 --- a/magicbees_src/magicbees/bees/BeeGenomeManager.java +++ b/magicbees_src/magicbees/bees/BeeGenomeManager.java @@ -62,7 +62,7 @@ public class BeeGenomeManager genome[EnumBeeChromosome.SPECIES.ordinal()] = BeeSpecies.SORCEROUS; genome[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.getBaseAllele("fertilityHigh"); genome[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.getBaseAllele("toleranceDown2"); - genome[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.getBaseAllele("toleranceDown1"); + genome[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.getBaseAllele("toleranceUp1"); return genome; } diff --git a/magicbees_src/magicbees/client/render/BeeRenderEffect.java b/magicbees_src/magicbees/client/render/BeeRenderEffect.java deleted file mode 100644 index 88abf99..0000000 --- a/magicbees_src/magicbees/client/render/BeeRenderEffect.java +++ /dev/null @@ -1,104 +0,0 @@ -package magicbees.client.render; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.FMLClientHandler; - - -import magicbees.main.CommonProxy; -import magicbees.main.MagicBees; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.world.World; -import net.minecraftforge.client.ForgeHooksClient; - -/** - * Borrowed from Forestry with some modifications. - */ -public class BeeRenderEffect extends EntityFX -{ - public int blendmode = 1; - private static String texture = "forestry:textures/items/particles/swarm_bee.png"; - - public BeeRenderEffect(World world, double x, double y, double z, float motionScaleX, float motionScaleY, float motionScaleZ, int color) - { - - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - - // Colour is stored in 4-byte int: XXRRGGBB - particleRed = (color >> 16 & 255) / 255.0F; - particleGreen = (color >> 8 & 255) / 255.0F; - particleBlue = (color & 255) / 255.0F; - - this.setParticleTextureIndex(0); - this.setSize(0.1F, 0.1F); - this.particleScale *= 0.2F; - this.particleMaxAge = (int) (20.0D / (Math.random() * 0.8D + 0.2D)); - this.noClip = true; - - this.motionX *= 0.119999999552965164D; - this.motionY *= 0.119999999552965164D; - this.motionZ *= 0.119999999552965164D; - - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 1.08D; - this.motionY *= 1.08D; - this.motionZ *= 1.08D; - - if (this.particleMaxAge-- <= 0) - { - this.setDead(); - } - } - - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) - { - - tessellator.draw(); - GL11.glPushMatrix(); - - GL11.glDepthMask(false); - GL11.glEnable(3042); - GL11.glBlendFunc(770, blendmode); - - FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - float f10 = 0.1F * particleScale; - float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX); - float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY); - float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ); - - // GL11.glRotatef(this.rand.nextFloat(), 0.0F, 1.0F, 0.0F); - tessellator.startDrawingQuads(); - tessellator.setBrightness(0x0000f0); - - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F); - tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1); - tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1); - tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0); - tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0); - - tessellator.draw(); - - GL11.glDisable(3042); - GL11.glDepthMask(true); - - GL11.glPopMatrix(); - GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */, MagicBees.proxy.getClientInstance().renderEngine.getTexture("/particles.png")); - tessellator.startDrawingQuads(); - } - -} diff --git a/magicbees_src/magicbees/main/ClientProxy.java b/magicbees_src/magicbees/main/ClientProxy.java index 9d8cc81..6c7a630 100644 --- a/magicbees_src/magicbees/main/ClientProxy.java +++ b/magicbees_src/magicbees/main/ClientProxy.java @@ -1,22 +1,20 @@ package magicbees.main; -import magicbees.client.render.BeeRenderEffect; import magicbees.client.render.EffectJarRenderer; import magicbees.tileentity.TileEntityEffectJar; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; import net.minecraft.world.World; 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 forestry.core.render.TextureManager; @SideOnly(Side.CLIENT) public class ClientProxy extends CommonProxy -{ - - public ClientProxy() { } - - @Override +{ @Override public void registerRenderers() { super.registerRenderers(); @@ -25,31 +23,4 @@ public class ClientProxy extends CommonProxy MinecraftForgeClient.registerItemRenderer(Config.effectJar.blockID, EffectJarRenderer.instance); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEffectJar.class, EffectJarRenderer.instance); } - - @Override - public void drawBeeEffects(World world, double xPos, double yPos, double zPos, int colour, int rangeX, int rangeY, int rangeZ) - { - // drawParticleEffects flag pulled from Forestry after configs - if (MagicBees.getConfig().DrawParticleEffects) - { - double spawnX; - double spawnY; - double spawnZ; - - if (world.rand.nextBoolean()) - { - spawnX = xPos + 0.5; - spawnY = yPos + 0.75; - spawnZ = zPos + 0.5; - } - else - { - spawnX = xPos + world.rand.nextInt(rangeX * 2) - rangeX; - spawnY = yPos + world.rand.nextInt(rangeY); - spawnZ = zPos + world.rand.nextInt(rangeZ * 2) - rangeZ; - } - - this.getClientInstance().effectRenderer.addEffect(new BeeRenderEffect(world, spawnX, spawnY, spawnZ, 0f, 0f, 0f, colour)); - } - } } diff --git a/magicbees_src/magicbees/main/CommonProxy.java b/magicbees_src/magicbees/main/CommonProxy.java index b8527b2..ece98d2 100644 --- a/magicbees_src/magicbees/main/CommonProxy.java +++ b/magicbees_src/magicbees/main/CommonProxy.java @@ -21,18 +21,6 @@ public class CommonProxy public static final String MODEL_TEXTURE_PATH = TEXTURE_PATH + "model/"; public static int RenderIdEffectJar; - - public CommonProxy() { } - - public void drawBeeEffects(World world, double xPos, double yPos, double zPos, int colour, int rangeX, int rangeY, int rangeZ) - { - // Does nothing in common. - } - - public Minecraft getClientInstance() - { - return FMLClientHandler.instance().getClient(); - } public void registerRenderers() { } diff --git a/magicbees_src/magicbees/main/MagicBees.java b/magicbees_src/magicbees/main/MagicBees.java index dd153b2..07590eb 100644 --- a/magicbees_src/magicbees/main/MagicBees.java +++ b/magicbees_src/magicbees/main/MagicBees.java @@ -4,6 +4,7 @@ import magicbees.bees.BeeManager; import magicbees.client.gui.GUIHandler; import magicbees.main.utils.CompatabilityManager; import magicbees.main.utils.CraftingManager; +import magicbees.main.utils.IMCManager; import magicbees.main.utils.LocalizationManager; import magicbees.main.utils.VersionInfo; import magicbees.main.utils.compat.ArsMagicaHelper; @@ -14,6 +15,7 @@ import magicbees.world.WorldGeneratorHandler; 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.NetworkMod; @@ -91,6 +93,12 @@ public class MagicBees VersionInfo.doVersionCheck(); } + @Mod.IMCCallback + public void handleIMCMessage(IMCEvent event) + { + IMCManager.handle(event); + } + public static Config getConfig() { return object.modConfig; diff --git a/magicbees_src/magicbees/main/utils/IMCManager.java b/magicbees_src/magicbees/main/utils/IMCManager.java new file mode 100644 index 0000000..bb80690 --- /dev/null +++ b/magicbees_src/magicbees/main/utils/IMCManager.java @@ -0,0 +1,64 @@ +package magicbees.main.utils; + +import magicbees.bees.AlleleEffectCrumbling; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCManager +{ + public static void handle(IMCEvent event) + { + for (IMCMessage message : event.getMessages()) + { + try + { + if (message.key.equals("addCrumblePair")) + { + handleCrumbleBlock(message); + } + else + { + FMLLog.warning("Magic Bees recieved an IMC Message from a mod %s " + + "but does not support messages keyed with %s.", + message.getSender(), message.key); + } + } + catch (Exception e) + { + FMLLog.warning("Magic Bees recieved an invalid IMC Message from a mod %s! Please inform " + + "the author of %s that they may not be correctly implementing message for key '%s'. Error details follow.", + message.getSender(), message.key); + FMLLog.info(e.getMessage()); + } + } + } + + private static void handleCrumbleBlock(IMCMessage message) throws Exception + { + NBTTagCompound root = message.getNBTValue(); + NBTBase source = root.getTag("source"); + NBTBase target = root.getTag("target"); + + if (source != null && source instanceof NBTTagCompound) + { + ItemStack sourceItem = ItemStack.loadItemStackFromNBT((NBTTagCompound)source); + if (target instanceof NBTTagCompound) + { + ItemStack targetItem = ItemStack.loadItemStackFromNBT((NBTTagCompound)target); + AlleleEffectCrumbling.addPairToMap(sourceItem, targetItem); + } + else + { + throw new Exception("Required tag 'target' was either empty, or not a valid ItemStack."); + } + } + else + { + throw new Exception("Required tag 'source' was either empty, or not a valid ItemStack."); + } + } +}