diff --git a/magicbees_res/assets/magicbees/lang/en_US.xml b/magicbees_res/assets/magicbees/lang/en_US.xml index a17ad47..aaf77cd 100644 --- a/magicbees_res/assets/magicbees/lang/en_US.xml +++ b/magicbees_res/assets/magicbees/lang/en_US.xml @@ -266,6 +266,13 @@ It is said they have been to a land ruled by a Great Wizard, and have taken the aspect of his city.|Apinomicon Apatine Day and night the whining droned on. I barricaded the windows and hid in the cellar, but everywhere the high-pitched noise of the apatine bees penetrated the walls and drove me to distraction.|Beekeeping 101 + + Mutable + Changeable in nature, mercurial in personality.|Apinomicon + Transmuting + "I could've sworn this was made out of stone yesterday!"|Sengir, Mad Apiarist + Crumbling + They have a corrosive effect on their surroundings, rapidly aging them.|Apinomicon Stark "These are unusually attracted to shards. This warrents further investigation."|Azanor, Master Thaumaturge @@ -350,6 +357,8 @@ Swiftness Time Warp Withering + Transmuting + Crumbling Aura Attract Purify Aura Aura Flux @@ -392,6 +401,8 @@ They collect fragments of metal and combine them into larger portions.|Apinomicon Gem They collect fragments of precious gems in their combs.|Apinomicon + Polymorphic + Reality seems to be somewhat volatile around bees of this family.|Apinomicon Thaumic These bees have an increased affinity to magic and aura.|Apinomicon Fleshy diff --git a/magicbees_res/changelog.txt b/magicbees_res/changelog.txt index 9bbea56..509cef0 100644 --- a/magicbees_res/changelog.txt +++ b/magicbees_res/changelog.txt @@ -1,3 +1,13 @@ +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. +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. Updating localization files (RU, DE) diff --git a/magicbees_src/magicbees/bees/Allele.java b/magicbees_src/magicbees/bees/Allele.java index f95593c..725aacd 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; @@ -26,6 +28,8 @@ public class Allele implements IAllele public static IAlleleEffect effectMoveSpeed; public static IAlleleEffect effectSlowSpeed; public static IAlleleEffect effectWithering; + public static IAlleleEffect effectTransmuting; + public static IAlleleEffect effectCrumbling; public static IAlleleEffect spawnBrainyZombie; public static IAlleleEffect spawnWisp; @@ -42,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); @@ -64,7 +70,6 @@ public class Allele implements IAllele else { Allele.flowerThaumcraft = Allele.flowerAuraNode = (IAlleleFlowers)Allele.getBaseAllele("flowersVanilla"); - Allele.spawnBrainyZombie = Allele.spawnBats = Allele.spawnWisp = (IAlleleEffect)Allele.getBaseAllele("effectNone"); } if (ArsMagicaHelper.isActive()) @@ -95,6 +100,9 @@ public class Allele implements IAllele Allele.effectMoveSpeed = new AlleleEffectPotion("MoveSpeed", Potion.moveSpeed, 10, false); Allele.effectSlowSpeed = new AlleleEffectPotion("SlowSpeed", Potion.moveSlowdown, 3, false).setMalicious(); Allele.effectWithering = new AlleleEffectPotion("Withering", Potion.wither, 10, false).setMalicious(); + + Allele.effectTransmuting = new AlleleEffectTransmuting("Transmuting", true); + Allele.effectCrumbling = new AlleleEffectCrumbling("Crumbling", true); Allele.spawnGhast = new AlleleEffectSpawnMob("Ghastly", false, "Ghast", "mob.ghast.moan") .setThrottle(2060).setChanceToSpawn(10).setMaxMobsInSpawnZone(1); 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 new file mode 100644 index 0000000..37398d1 --- /dev/null +++ b/magicbees_src/magicbees/bees/AlleleEffectCrumbling.java @@ -0,0 +1,90 @@ +package magicbees.bees; + +import java.util.HashMap; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; + +public class AlleleEffectCrumbling extends AlleleEffect +{ + 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, 600); + + 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 + public IEffectData validateStorage(IEffectData storedData) + { + if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) + { + storedData = new magicbees.bees.EffectData(1, 0, 0); + } + return storedData; + } + + @Override + protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) + { + World world = housing.getWorld(); + // Get random coords within territory + int xCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]); + xCoord = housing.getXCoord() + world.rand.nextInt(xCoord) - xCoord / 2; + int yCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]); + yCoord = housing.getYCoord() + world.rand.nextInt(yCoord) - yCoord / 2; + int zCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]); + zCoord = housing.getZCoord() + world.rand.nextInt(zCoord) - zCoord / 2; + + boolean success = false; + Block block = Block.blocksList[world.getBlockId(xCoord, yCoord, zCoord)]; + if (block != null) + { + ItemStack source = new ItemStack(block, 1, world.getBlockMetadata(xCoord, yCoord, zCoord)); + for (ItemStack key : crumbleMap.keySet()) + { + if (OreDictionary.itemMatches(source, key, false)) + { + ItemStack target = crumbleMap.get(key); + world.setBlock(xCoord, yCoord, zCoord, target.itemID, target.getItemDamage(), 2); + + break; + } + } + } + + storedData.setInteger(0, 0); + + return storedData; + } + +} diff --git a/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java b/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java new file mode 100644 index 0000000..7666368 --- /dev/null +++ b/magicbees_src/magicbees/bees/AlleleEffectTransmuting.java @@ -0,0 +1,118 @@ +package magicbees.bees; + +import java.util.Locale; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.oredict.OreDictionary; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; + +public class AlleleEffectTransmuting extends AlleleEffect +{ + public AlleleEffectTransmuting(String id, boolean isDominant) + { + super(id, isDominant, 900); + } + + @Override + public IEffectData validateStorage(IEffectData storedData) + { + if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) + { + storedData = new magicbees.bees.EffectData(1, 0, 0); + } + return storedData; + } + + @Override + protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) + { + World world = housing.getWorld(); + // Get random coords within territory + int xCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]); + xCoord = housing.getXCoord() + world.rand.nextInt(xCoord) - xCoord / 2; + int yCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]); + yCoord = housing.getYCoord() + world.rand.nextInt(yCoord) - yCoord / 2; + int zCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]); + zCoord = housing.getZCoord() + world.rand.nextInt(zCoord) - zCoord / 2; + + // Check if == stone + boolean doTransmute = false; + Block block = Block.blocksList[world.getBlockId(xCoord, yCoord, zCoord)]; + if (block == null || block == Block.stone || block == Block.cobblestone) + { + doTransmute = true; + } + else if (block != null) + { + ItemStack cobbleItem = new ItemStack(Block.cobblestone); + ItemStack stoneItem = new ItemStack(Block.stone); + ItemStack testItem = new ItemStack(block); + doTransmute = OreDictionary.itemMatches(cobbleItem, testItem, false) || OreDictionary.itemMatches(stoneItem, cobbleItem, false); + } + + // Transmute to something. + if (doTransmute) + { + BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord); + // Gogo shortcutting logic operators! + boolean tryThis = trySpawnAbyssalStone(world, biome, xCoord, yCoord, zCoord) || + trySpawnQuarriedStone(world, biome, xCoord, yCoord, zCoord) || + trySpawnSandstone(world, biome, xCoord, yCoord, zCoord); + } + storedData.setInteger(0, 0); + + return storedData; + } + + private boolean trySpawnQuarriedStone(World world, BiomeGenBase biome, int x, int y, int z) + { + boolean flag = false; + if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.FOREST) && + !BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.FROZEN)) + { + ItemStack item = GameRegistry.findItemStack("Railcraft", "stone.abyssal", 1); + if (item != null) + { + world.setBlock(x, y, z, item.itemID, item.getItemDamage(), 2); + flag = true; + } + } + return flag; + } + + private boolean trySpawnAbyssalStone(World world, BiomeGenBase biome, int x, int y, int z) + { + boolean flag = false; + if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WATER) && + biome.biomeName.toLowerCase(Locale.ENGLISH).contains("river")) + { + ItemStack item = GameRegistry.findItemStack("Railcraft", "stone.quarried", 1); + if (item != null) + { + world.setBlock(x, y, z, item.itemID, item.getItemDamage(), 2); + flag = true; + } + } + return flag; + } + + private boolean trySpawnSandstone(World world, BiomeGenBase biome, int x, int y, int z) + { + boolean flag = false; + if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.DESERT)) + { + world.setBlock(x, y, z, Block.sandStone.blockID); + flag = true; + } + return flag; + } + +} diff --git a/magicbees_src/magicbees/bees/BeeClassification.java b/magicbees_src/magicbees/bees/BeeClassification.java index fa4cf8a..0e61eb8 100644 --- a/magicbees_src/magicbees/bees/BeeClassification.java +++ b/magicbees_src/magicbees/bees/BeeClassification.java @@ -27,6 +27,7 @@ public enum BeeClassification implements IClassification METALLIC("Metallic", "Metalliapis"), GEM("Gem", "Lapidapis"), + TRANSMUTING("Transmuting", "Transmutapis"), THAUMIC("Thaumic", "Thaumiapis"), FLESHY("Fleshy", "Carnosapis"), diff --git a/magicbees_src/magicbees/bees/BeeGenomeManager.java b/magicbees_src/magicbees/bees/BeeGenomeManager.java index f924311..f3dd912 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; } @@ -718,6 +718,46 @@ public class BeeGenomeManager return genome; } + public static IAllele[] getTemplateMutableBase() + { + IAllele[] genome = getTemplateModBase(); + + genome[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.getBaseAllele("lifespanShortest"); + genome[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.getBaseAllele("toleranceUp1"); + genome[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.getBaseAllele("toleranceDown2"); + + return genome; + } + + public static IAllele[] getTemplateMutable() + { + IAllele[] genome = getTemplateMutableBase(); + + genome[EnumBeeChromosome.SPECIES.ordinal()] = BeeSpecies.MUTABLE; + + return genome; + } + + public static IAllele[] getTemplateTransmuting() + { + IAllele[] genome = getTemplateMutableBase(); + + genome[EnumBeeChromosome.SPECIES.ordinal()] = BeeSpecies.TRANSMUTING; + genome[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectTransmuting; + + return genome; + } + + public static IAllele[] getTemplateCrumbling() + { + IAllele[] genome = getTemplateMutableBase(); + + genome[EnumBeeChromosome.SPECIES.ordinal()] = BeeSpecies.CRUMBLING; + genome[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectCrumbling; + + return genome; + } + private static IAllele[] getTemplateTCBase() { IAllele[] genome = getTemplateModBase(); diff --git a/magicbees_src/magicbees/bees/BeeMutation.java b/magicbees_src/magicbees/bees/BeeMutation.java index 85b78be..a2a42bf 100644 --- a/magicbees_src/magicbees/bees/BeeMutation.java +++ b/magicbees_src/magicbees/bees/BeeMutation.java @@ -113,6 +113,10 @@ public class BeeMutation implements IBeeMutation new BeeMutation(Allele.getBaseSpecies("Imperial"), BeeSpecies.ABANDONED, BeeSpecies.DRACONIC, 6) .setBiomeRequired(BiomeDictionary.Type.END); + new BeeMutation(BeeSpecies.UNUSUAL, BeeSpecies.ELDRITCH, BeeSpecies.MUTABLE, 12); + //new BeeMutation(BeeSpecies.UNUSUAL, BeeSpecies.MUTABLE, BeeSpecies.TRANSMUTING, 9); + new BeeMutation(BeeSpecies.UNUSUAL, BeeSpecies.MUTABLE, BeeSpecies.CRUMBLING, 9); + if (BeeSpecies.COPPER.isActive()) { new BeeMutation(Allele.getBaseSpecies("Industrious"), Allele.getBaseSpecies("Meadows"), BeeSpecies.COPPER, 12) @@ -123,7 +127,7 @@ public class BeeMutation implements IBeeMutation new BeeMutation(Allele.getBaseSpecies("Industrious"), Allele.getBaseSpecies("Forest"), BeeSpecies.TIN, 12) .setBlockRequired("blockTin"); } - new BeeMutation(Allele.getBaseSpecies("Common"), Allele.getBaseSpecies("Industrious"), BeeSpecies.IRON, 100) + new BeeMutation(Allele.getBaseSpecies("Common"), Allele.getBaseSpecies("Industrious"), BeeSpecies.IRON, 12) .setBlockRequired(Block.blockIron); if (BeeSpecies.LEAD.isActive()) { @@ -249,7 +253,7 @@ public class BeeMutation implements IBeeMutation if (EquivalentExchangeHelper.isActive()) { - new BeeMutation(Allele.getBaseSpecies("Frugal"), BeeSpecies.ELDRITCH, BeeSpecies.EE_MINIUM, 8); + new BeeMutation(Allele.getBaseSpecies("Frugal"), BeeSpecies.MUTABLE, BeeSpecies.EE_MINIUM, 8); } } diff --git a/magicbees_src/magicbees/bees/BeeSpecies.java b/magicbees_src/magicbees/bees/BeeSpecies.java index 96f1f12..c401bb8 100644 --- a/magicbees_src/magicbees/bees/BeeSpecies.java +++ b/magicbees_src/magicbees/bees/BeeSpecies.java @@ -159,6 +159,13 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider BeeClassification.GEM, 0x005300, 0x17DD62, EnumTemperature.NORMAL, EnumHumidity.NORMAL, true, false), APATITE("Apatite", "apatite", BeeClassification.GEM, 0x2EA7EC, 0x001D51, EnumTemperature.NORMAL, EnumHumidity.NORMAL, false, false), + + MUTABLE("Mutable", "mutable", + BeeClassification.TRANSMUTING, 0xDBB24C, 0xE0D5A6, EnumTemperature.NORMAL, EnumHumidity.NORMAL, false, false), + TRANSMUTING("Transmuting", "transmuting", + BeeClassification.TRANSMUTING, 0xDBB24C, 0xA2D2D8, EnumTemperature.NORMAL, EnumHumidity.NORMAL, false, false), + CRUMBLING("Crumbling", "crumbling", + BeeClassification.TRANSMUTING, 0xDBB24C, 0xDBA4A4, EnumTemperature.HOT, EnumHumidity.ARID, false, false), // --------- Thaumcraft Bees --------------------------------------------------------------------------------------- TC_STARK("TCStark", "torridae", // Stark @@ -578,6 +585,19 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider .setGenome(BeeGenomeManager.getTemplateApatite()) .register(); + MUTABLE.addProduct(new ItemStack(Config.fBeeComb, 1, ForestryHelper.Comb.PARCHED.ordinal()), 30) + .setGenome(BeeGenomeManager.getTemplateMutable()) + .register(); + TRANSMUTING.addProduct(new ItemStack(Config.fBeeComb, 1, ForestryHelper.Comb.PARCHED.ordinal()), 10) + .addProduct(new ItemStack(Config.fBeeComb, 1, ForestryHelper.Comb.SILKY.ordinal()), 10) + .addProduct(new ItemStack(Config.fBeeComb, 1, ForestryHelper.Comb.SIMMERING.ordinal()), 10) + .setGenome(BeeGenomeManager.getTemplateTransmuting()) + ;//.register(); + CRUMBLING.addProduct(new ItemStack(Config.fBeeComb, 1, ForestryHelper.Comb.POWDERY.ordinal()), 20) + .addProduct(new ItemStack(Config.fBeeComb, 1 , ForestryHelper.Comb.COCOA.ordinal()), 20) + .setGenome(BeeGenomeManager.getTemplateCrumbling()) + .register(); + TC_STARK.addProduct(Config.combs.getStackForType(CombType.HARMONIZING), 10) .setGenome(BeeGenomeManager.getTemplateTCStark()) diff --git a/magicbees_src/magicbees/client/render/BeeRenderEffect.java b/magicbees_src/magicbees/client/render/BeeRenderEffect.java deleted file mode 100644 index 5476f0d..0000000 --- a/magicbees_src/magicbees/client/render/BeeRenderEffect.java +++ /dev/null @@ -1,102 +0,0 @@ -package magicbees.client.render; - -import magicbees.main.MagicBees; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.FMLClientHandler; - -/** - * Borrowed from Forestry with some modifications. - */ -public class BeeRenderEffect extends EntityFX -{ - public int blendmode = 1; - private static ResourceLocation texture = new ResourceLocation("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.func_110577_a(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, MagicBees.proxy.getClientInstance().renderEngine.func_110577_a(texture)); - 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 7cc4b2b..56bbffc 100644 --- a/magicbees_src/magicbees/main/CommonProxy.java +++ b/magicbees_src/magicbees/main/CommonProxy.java @@ -31,18 +31,6 @@ public class CommonProxy public static final String GUI_PATH = TEXTURE_PATH + "gui/"; 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."); + } + } +}